0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-01-20 16:01:53 +00:00

Merge commit '3216eb03ddddc057bb18fa4dd02b7935a604f71f' into integrated

Conflicts:

	sysdep/linux/netlink.c
This commit is contained in:
Ondrej Zajicek 2014-05-02 18:05:57 +02:00
commit c0821881fe
3 changed files with 26 additions and 11 deletions

View File

@ -225,7 +225,7 @@ static inline unsigned ip6_hash(ip6_addr a)
static inline u32 ip6_hash32(ip6_addr a) static inline u32 ip6_hash32(ip6_addr a)
{ {
/* Returns a 32-bit hash key, although low-order bits are not mixed */ /* Returns a 32-bit hash key, although low-order bits are not mixed */
u32 x = _I0(*a) ^ _I1(*a) ^ _I2(*a) ^ _I3(*a); u32 x = _I0(a) ^ _I1(a) ^ _I2(a) ^ _I3(a);
return x ^ (x << 16) ^ (x << 24); return x ^ (x << 16) ^ (x << 24);
} }

View File

@ -600,7 +600,7 @@ krt_read_ifannounce(struct ks_msg *msg)
} }
static void static void
krt_read_ifinfo(struct ks_msg *msg) krt_read_ifinfo(struct ks_msg *msg, int scan)
{ {
struct if_msghdr *ifm = (struct if_msghdr *)&msg->rtm; struct if_msghdr *ifm = (struct if_msghdr *)&msg->rtm;
void *body = (void *)(ifm + 1); void *body = (void *)(ifm + 1);
@ -673,11 +673,14 @@ krt_read_ifinfo(struct ks_msg *msg)
else else
f.flags |= IF_MULTIACCESS; /* NBMA */ f.flags |= IF_MULTIACCESS; /* NBMA */
if_update(&f); iface = if_update(&f);
if (!scan)
if_end_partial_update(iface);
} }
static void static void
krt_read_addr(struct ks_msg *msg) krt_read_addr(struct ks_msg *msg, int scan)
{ {
struct ifa_msghdr *ifam = (struct ifa_msghdr *)&msg->rtm; struct ifa_msghdr *ifam = (struct ifa_msghdr *)&msg->rtm;
void *body = (void *)(ifam + 1); void *body = (void *)(ifam + 1);
@ -787,6 +790,9 @@ krt_read_addr(struct ks_msg *msg)
ifa_update(&ifa); ifa_update(&ifa);
else else
ifa_delete(&ifa); ifa_delete(&ifa);
if (!scan)
if_end_partial_update(iface);
} }
static void static void
@ -806,11 +812,11 @@ krt_read_msg(struct proto *p, struct ks_msg *msg, int scan)
krt_read_ifannounce(msg); krt_read_ifannounce(msg);
break; break;
case RTM_IFINFO: case RTM_IFINFO:
krt_read_ifinfo(msg); krt_read_ifinfo(msg, scan);
break; break;
case RTM_NEWADDR: case RTM_NEWADDR:
case RTM_DELADDR: case RTM_DELADDR:
krt_read_addr(msg); krt_read_addr(msg, scan);
break; break;
default: default:
break; break;

View File

@ -453,12 +453,16 @@ nl_parse_link(struct nlmsghdr *h, int scan)
f.flags |= IF_MULTIACCESS | IF_BROADCAST | IF_MULTICAST; f.flags |= IF_MULTIACCESS | IF_BROADCAST | IF_MULTICAST;
else else
f.flags |= IF_MULTIACCESS; /* NBMA */ f.flags |= IF_MULTIACCESS; /* NBMA */
if_update(&f);
ifi = if_update(&f);
if (!scan)
if_end_partial_update(ifi);
} }
} }
static void static void
nl_parse_addr(struct nlmsghdr *h) nl_parse_addr(struct nlmsghdr *h, int scan)
{ {
struct ifaddrmsg *i; struct ifaddrmsg *i;
struct rtattr *a[IFA_ANYCAST+1]; struct rtattr *a[IFA_ANYCAST+1];
@ -549,10 +553,15 @@ nl_parse_addr(struct nlmsghdr *h)
DBG("KIF: IF%d(%s): %s IPA %I, flg %x, net %I/%d, brd %I, opp %I\n", DBG("KIF: IF%d(%s): %s IPA %I, flg %x, net %I/%d, brd %I, opp %I\n",
ifa.iface->index, ifa.iface->name, new ? "added" : "removed", ifa.iface->index, ifa.iface->name, new ? "added" : "removed",
ifa.ip, ifa.flags, ifa.prefix, ifa.pxlen, ifa.brd, ifa.opposite); ifa.ip, ifa.flags, ifa.prefix, ifa.pxlen, ifa.brd, ifa.opposite);
if (new) if (new)
ifa_update(&ifa); ifa_update(&ifa);
else else
ifa_delete(&ifa); ifa_delete(&ifa);
if (!scan)
if_end_partial_update(ifa.iface);
return; return;
malformed: malformed:
@ -580,14 +589,14 @@ kif_do_scan(struct kif_proto *p UNUSED)
nl_request_dump(PF_INET, RTM_GETADDR); nl_request_dump(PF_INET, RTM_GETADDR);
while (h = nl_get_scan()) while (h = nl_get_scan())
if (h->nlmsg_type == RTM_NEWADDR || h->nlmsg_type == RTM_DELADDR) if (h->nlmsg_type == RTM_NEWADDR || h->nlmsg_type == RTM_DELADDR)
nl_parse_addr(h); nl_parse_addr(h, 1);
else else
log(L_DEBUG "nl_scan_ifaces: Unknown packet received (type=%d)", h->nlmsg_type); log(L_DEBUG "nl_scan_ifaces: Unknown packet received (type=%d)", h->nlmsg_type);
nl_request_dump(PF_INET6, RTM_GETADDR); nl_request_dump(PF_INET6, RTM_GETADDR);
while (h = nl_get_scan()) while (h = nl_get_scan())
if (h->nlmsg_type == RTM_NEWADDR || h->nlmsg_type == RTM_DELADDR) if (h->nlmsg_type == RTM_NEWADDR || h->nlmsg_type == RTM_DELADDR)
nl_parse_addr(h); nl_parse_addr(h, 1);
else else
log(L_DEBUG "nl_scan_ifaces: Unknown packet received (type=%d)", h->nlmsg_type); log(L_DEBUG "nl_scan_ifaces: Unknown packet received (type=%d)", h->nlmsg_type);
@ -1000,7 +1009,7 @@ nl_async_msg(struct nlmsghdr *h)
case RTM_NEWADDR: case RTM_NEWADDR:
case RTM_DELADDR: case RTM_DELADDR:
DBG("KRT: Received async address notification (%d)\n", h->nlmsg_type); DBG("KRT: Received async address notification (%d)\n", h->nlmsg_type);
nl_parse_addr(h); nl_parse_addr(h, 0);
break; break;
default: default:
DBG("KRT: Received unknown async notification (%d)\n", h->nlmsg_type); DBG("KRT: Received unknown async notification (%d)\n", h->nlmsg_type);