mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-02-07 04:34:04 -05:00
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
@ -617,6 +617,7 @@ vlan_read_ifnames(struct nlmsghdr *h, size_t len, int del,
|
|||||||
struct ifinfomsg *ifi;
|
struct ifinfomsg *ifi;
|
||||||
int attrlen, nlmsg_len, rta_len;
|
int attrlen, nlmsg_len, rta_len;
|
||||||
struct rtattr *attr;
|
struct rtattr *attr;
|
||||||
|
char ifname[IFNAMSIZ + 1];
|
||||||
|
|
||||||
if (len < sizeof(*ifi))
|
if (len < sizeof(*ifi))
|
||||||
return;
|
return;
|
||||||
@ -631,29 +632,39 @@ vlan_read_ifnames(struct nlmsghdr *h, size_t len, int del,
|
|||||||
|
|
||||||
attr = (struct rtattr *) (((char *) ifi) + nlmsg_len);
|
attr = (struct rtattr *) (((char *) ifi) + nlmsg_len);
|
||||||
|
|
||||||
|
os_memset(ifname, 0, sizeof(ifname));
|
||||||
rta_len = RTA_ALIGN(sizeof(struct rtattr));
|
rta_len = RTA_ALIGN(sizeof(struct rtattr));
|
||||||
while (RTA_OK(attr, attrlen)) {
|
while (RTA_OK(attr, attrlen)) {
|
||||||
char ifname[IFNAMSIZ + 1];
|
|
||||||
|
|
||||||
if (attr->rta_type == IFLA_IFNAME) {
|
if (attr->rta_type == IFLA_IFNAME) {
|
||||||
int n = attr->rta_len - rta_len;
|
int n = attr->rta_len - rta_len;
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
os_memset(ifname, 0, sizeof(ifname));
|
if ((size_t) n >= sizeof(ifname))
|
||||||
|
n = sizeof(ifname) - 1;
|
||||||
if ((size_t) n > sizeof(ifname))
|
|
||||||
n = sizeof(ifname);
|
|
||||||
os_memcpy(ifname, ((char *) attr) + rta_len, n);
|
os_memcpy(ifname, ((char *) attr) + rta_len, n);
|
||||||
|
|
||||||
if (del)
|
|
||||||
vlan_dellink(ifname, hapd);
|
|
||||||
else
|
|
||||||
vlan_newlink(ifname, hapd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
attr = RTA_NEXT(attr, attrlen);
|
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;
|
h = (struct nlmsghdr *) buf;
|
||||||
while (left >= (int) sizeof(*h)) {
|
while (NLMSG_OK(h, left)) {
|
||||||
int len, plen;
|
int len, plen;
|
||||||
|
|
||||||
len = h->nlmsg_len;
|
len = h->nlmsg_len;
|
||||||
@ -698,9 +709,7 @@ static void vlan_event_receive(int sock, void *eloop_ctx, void *sock_ctx)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = NLMSG_ALIGN(len);
|
h = NLMSG_NEXT(h, left);
|
||||||
left -= len;
|
|
||||||
h = (struct nlmsghdr *) ((char *) h + len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (left > 0) {
|
if (left > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user