summaryrefslogtreecommitdiff
path: root/zebra/if_netlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/if_netlink.c')
-rw-r--r--zebra/if_netlink.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c
index 0d08155178..5a42e0c8f1 100644
--- a/zebra/if_netlink.c
+++ b/zebra/if_netlink.c
@@ -393,7 +393,7 @@ static int get_iflink_speed(const char *ifname)
memset(&ifdata, 0, sizeof(ifdata));
/* set interface name */
- strcpy(ifdata.ifr_name, ifname);
+ strlcpy(ifdata.ifr_name, ifname, sizeof(ifdata.ifr_name));
/* initialize ethtool interface */
memset(&ecmd, 0, sizeof(ecmd));
@@ -830,18 +830,24 @@ static int netlink_address(int cmd, int family, struct interface *ifp,
req.ifa.ifa_family = family;
req.ifa.ifa_index = ifp->ifindex;
- req.ifa.ifa_prefixlen = p->prefixlen;
addattr_l(&req.n, sizeof req, IFA_LOCAL, &p->u.prefix, bytelen);
- if (family == AF_INET && cmd == RTM_NEWADDR) {
- if (!CONNECTED_PEER(ifc) && ifc->destination) {
+ if (family == AF_INET) {
+ if (CONNECTED_PEER(ifc)) {
+ p = ifc->destination;
+ addattr_l(&req.n, sizeof req, IFA_ADDRESS, &p->u.prefix,
+ bytelen);
+ } else if (cmd == RTM_NEWADDR && ifc->destination) {
p = ifc->destination;
addattr_l(&req.n, sizeof req, IFA_BROADCAST,
&p->u.prefix, bytelen);
}
}
+ /* p is now either ifc->address or ifc->destination */
+ req.ifa.ifa_prefixlen = p->prefixlen;
+
if (CHECK_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY))
SET_FLAG(req.ifa.ifa_flags, IFA_F_SECONDARY);
@@ -993,14 +999,12 @@ int netlink_interface_addr(struct sockaddr_nl *snl, struct nlmsghdr *h,
*/
if (!(ifa->ifa_flags
& (IFA_F_DADFAILED | IFA_F_TENTATIVE)))
- connected_add_ipv6(
- ifp, flags, (struct in6_addr *)addr,
- ifa->ifa_prefixlen,
- (struct in6_addr *)broad, label);
+ connected_add_ipv6(ifp, flags,
+ (struct in6_addr *)addr,
+ ifa->ifa_prefixlen, label);
} else
connected_delete_ipv6(ifp, (struct in6_addr *)addr,
- ifa->ifa_prefixlen,
- (struct in6_addr *)broad);
+ ifa->ifa_prefixlen);
}
return 0;