aboutgitcodebugslistschat
path: root/netlink.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-10-19 09:08:06 +0200
committerStefano Brivio <sbrivio@redhat.com>2021-10-19 09:08:06 +0200
commit5496074862b8ec62a6f50b87d96a65c771b504a6 (patch)
tree5907a36ef211e2c22950b84214b9742aaf8b2762 /netlink.c
parent8a874ecf585bc14ff4789d5e0f2e35aad071d6a6 (diff)
downloadpasst-5496074862b8ec62a6f50b87d96a65c771b504a6.tar
passt-5496074862b8ec62a6f50b87d96a65c771b504a6.tar.gz
passt-5496074862b8ec62a6f50b87d96a65c771b504a6.tar.bz2
passt-5496074862b8ec62a6f50b87d96a65c771b504a6.tar.lz
passt-5496074862b8ec62a6f50b87d96a65c771b504a6.tar.xz
passt-5496074862b8ec62a6f50b87d96a65c771b504a6.tar.zst
passt-5496074862b8ec62a6f50b87d96a65c771b504a6.zip
netlink: NETLINK_GET_STRICT_CHK is not available on older kernels
For example on 4.19. Don't fail if we can't set it, filter on interface index in nl_addr(). Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'netlink.c')
-rw-r--r--netlink.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/netlink.c b/netlink.c
index 10d8a92..2e72568 100644
--- a/netlink.c
+++ b/netlink.c
@@ -50,14 +50,15 @@ static int __nl_sock_init(void *arg)
int *s = &nl_sock, v = 1;
ns:
- if (((*s) = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE)) < 0 ||
- bind(*s, (struct sockaddr *)&addr, sizeof(addr)) ||
- setsockopt(*s, SOL_NETLINK, NETLINK_GET_STRICT_CHK, &v, sizeof(v)))
+ if (((*s) = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE)) < 0 ||
+ bind(*s, (struct sockaddr *)&addr, sizeof(addr)))
*s = -1;
if (*s == -1 || !c || s == &nl_sock_ns)
return 0;
+ setsockopt(*s, SOL_NETLINK, NETLINK_GET_STRICT_CHK, &v, sizeof(v));
+
ns_enter((struct ctx *)arg);
s = &nl_sock_ns;
goto ns;
@@ -425,6 +426,8 @@ void nl_addr(int ns, unsigned int ifi, sa_family_t af,
goto next;
ifa = (struct ifaddrmsg *)NLMSG_DATA(nh);
+ if (ifa->ifa_index != ifi)
+ goto next;
for (rta = (struct rtattr *)IFA_RTA(ifa), na = RTM_PAYLOAD(nh);
RTA_OK(rta, na); rta = RTA_NEXT(rta, na)) {