VLAN: Clean up RTM_NEW/DELLINK processing
This uses couple of additional helper macros and prints more debug information to make the VLAN events easier to analyze. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
parent
47e5fbde44
commit
eeb1cb28a2
1 changed files with 23 additions and 14 deletions
|
@ -617,6 +617,7 @@ vlan_read_ifnames(struct nlmsghdr *h, size_t len, int del,
|
|||
struct ifinfomsg *ifi;
|
||||
int attrlen, nlmsg_len, rta_len;
|
||||
struct rtattr *attr;
|
||||
char ifname[IFNAMSIZ + 1];
|
||||
|
||||
if (len < sizeof(*ifi))
|
||||
return;
|
||||
|
@ -631,29 +632,39 @@ vlan_read_ifnames(struct nlmsghdr *h, size_t len, int del,
|
|||
|
||||
attr = (struct rtattr *) (((char *) ifi) + nlmsg_len);
|
||||
|
||||
os_memset(ifname, 0, sizeof(ifname));
|
||||
rta_len = RTA_ALIGN(sizeof(struct rtattr));
|
||||
while (RTA_OK(attr, attrlen)) {
|
||||
char ifname[IFNAMSIZ + 1];
|
||||
|
||||
if (attr->rta_type == IFLA_IFNAME) {
|
||||
int n = attr->rta_len - rta_len;
|
||||
if (n < 0)
|
||||
break;
|
||||
|
||||
os_memset(ifname, 0, sizeof(ifname));
|
||||
|
||||
if ((size_t) n > sizeof(ifname))
|
||||
n = sizeof(ifname);
|
||||
if ((size_t) n >= sizeof(ifname))
|
||||
n = sizeof(ifname) - 1;
|
||||
os_memcpy(ifname, ((char *) attr) + rta_len, n);
|
||||
|
||||
if (del)
|
||||
vlan_dellink(ifname, hapd);
|
||||
else
|
||||
vlan_newlink(ifname, hapd);
|
||||
}
|
||||
|
||||
attr = RTA_NEXT(attr, attrlen);
|
||||
}
|
||||
|
||||
if (!ifname[0])
|
||||
return;
|
||||
|
||||
wpa_printf(MSG_DEBUG,
|
||||
"VLAN: RTM_%sLINK: ifi_index=%d ifname=%s ifi_family=%d ifi_flags=0x%x (%s%s%s%s)",
|
||||
del ? "DEL" : "NEW",
|
||||
ifi->ifi_index, ifname, ifi->ifi_family, ifi->ifi_flags,
|
||||
(ifi->ifi_flags & IFF_UP) ? "[UP]" : "",
|
||||
(ifi->ifi_flags & IFF_RUNNING) ? "[RUNNING]" : "",
|
||||
(ifi->ifi_flags & IFF_LOWER_UP) ? "[LOWER_UP]" : "",
|
||||
(ifi->ifi_flags & IFF_DORMANT) ? "[DORMANT]" : "");
|
||||
|
||||
if (del)
|
||||
vlan_dellink(ifname, hapd);
|
||||
else
|
||||
vlan_newlink(ifname, hapd);
|
||||
}
|
||||
|
||||
|
||||
|
@ -677,7 +688,7 @@ static void vlan_event_receive(int sock, void *eloop_ctx, void *sock_ctx)
|
|||
}
|
||||
|
||||
h = (struct nlmsghdr *) buf;
|
||||
while (left >= (int) sizeof(*h)) {
|
||||
while (NLMSG_OK(h, left)) {
|
||||
int len, plen;
|
||||
|
||||
len = h->nlmsg_len;
|
||||
|
@ -698,9 +709,7 @@ static void vlan_event_receive(int sock, void *eloop_ctx, void *sock_ctx)
|
|||
break;
|
||||
}
|
||||
|
||||
len = NLMSG_ALIGN(len);
|
||||
left -= len;
|
||||
h = (struct nlmsghdr *) ((char *) h + len);
|
||||
h = NLMSG_NEXT(h, left);
|
||||
}
|
||||
|
||||
if (left > 0) {
|
||||
|
|
Loading…
Reference in a new issue