aboutsummaryrefslogtreecommitdiffstats
path: root/sysdep
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2020-03-05 23:51:28 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2020-03-07 05:11:21 +0100
commite2630a494ebc90bee97729ebe92a1bb9fd8bb611 (patch)
tree3df0a43a9b0f854015cabb06a190b82657d59642 /sysdep
parent1ad98965c5eacd5c5f468beac146dfd0d63c83f2 (diff)
downloadbird-e2630a494ebc90bee97729ebe92a1bb9fd8bb611.tar.gz
Netlink: Handle interfaces with missing broadcast addresses
Diffstat (limited to 'sysdep')
-rw-r--r--sysdep/linux/netlink.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/sysdep/linux/netlink.c b/sysdep/linux/netlink.c
index 25c078c1..856869ac 100644
--- a/sysdep/linux/netlink.c
+++ b/sysdep/linux/netlink.c
@@ -953,18 +953,15 @@ nl_parse_addr4(struct ifaddrmsg *i, int scan, int new)
if (i->ifa_prefixlen == IP4_MAX_PREFIX_LENGTH - 2)
ifa.opposite = ipa_opposite_m2(ifa.ip);
- if ((ifi->flags & IF_BROADCAST) && a[IFA_BROADCAST])
- {
- ip4_addr xbrd = rta_get_ip4(a[IFA_BROADCAST]);
- ip4_addr ybrd = ip4_or(ipa_to_ip4(ifa.ip), ip4_not(ip4_mkmask(i->ifa_prefixlen)));
-
- if (ip4_equal(xbrd, net4_prefix(&ifa.prefix)) || ip4_equal(xbrd, ybrd))
- ifa.brd = ipa_from_ip4(xbrd);
- else if (ifi->flags & IF_TMP_DOWN) /* Complain only during the first scan */
- {
- log(L_ERR "KIF: Invalid broadcast address %I4 for %s", xbrd, ifi->name);
- ifa.brd = ipa_from_ip4(ybrd);
- }
+ if (ifi->flags & IF_BROADCAST)
+ {
+ /* If kernel offers us a broadcast address, we trust it */
+ if (a[IFA_BROADCAST])
+ ifa.brd = ipa_from_ip4(rta_get_ip4(a[IFA_BROADCAST]));
+ /* Otherwise we create one (except for /31) */
+ else if (i->ifa_prefixlen < (IP4_MAX_PREFIX_LENGTH - 1))
+ ifa.brd = ipa_from_ip4(ip4_or(ipa_to_ip4(ifa.ip),
+ ip4_not(ip4_mkmask(i->ifa_prefixlen))));
}
}