fb.pos[0] = '\0';
return consumed;
}
+
+int sockunion_is_null(const union sockunion *su)
+{
+ unsigned char null_s6_addr[16] = {0};
+
+ switch (sockunion_family(su)) {
+ case AF_UNSPEC:
+ return 1;
+ case AF_INET:
+ return (su->sin.sin_addr.s_addr == 0);
+ case AF_INET6:
+ return !memcmp(su->sin6.sin6_addr.s6_addr, null_s6_addr,
+ sizeof(null_s6_addr));
+ default:
+ return 0;
+ }
+}
extern union sockunion *sockunion_dup(const union sockunion *);
extern void sockunion_free(union sockunion *);
extern void sockunion_init(union sockunion *);
+extern int sockunion_is_null(const union sockunion *su);
#ifdef _FRR_ATTRIBUTE_PRINTFRR
#pragma FRR printfrr_ext "%pSU" (union sockunion *)
struct route_info *ri = rn->info;
if (!ri->ifp && !ri->nhrp_ifp
- && sockunion_family(&ri->via) == AF_UNSPEC) {
+ && sockunion_is_null(&ri->via)) {
XFREE(MTYPE_NHRP_ROUTE, rn->info);
route_unlock_node(rn);
}
struct route_node *rn;
struct route_info *ri;
- rn = nhrp_route_update_get(
- p, (sockunion_family(nexthop) != AF_UNSPEC) || ifp);
+ rn = nhrp_route_update_get(p, !sockunion_is_null(nexthop) || ifp);
if (rn) {
ri = rn->info;
ri->via = *nexthop;
sockunion2str(&nexthop_addr, buf, sizeof(buf)),
ifp ? ifp->name : "(none)");
- nhrp_route_update_zebra(&api.prefix, &nexthop_addr, ifp);
+ nhrp_route_update_zebra(&api.prefix, &nexthop_addr, added ? ifp : NULL);
nhrp_shortcut_prefix_change(&api.prefix, !added);
return 0;