Date: Mon, 9 Nov 2015 10:11:15 +0000 (UTC) From: "Alexander V. Chernikov" <melifaro@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r290603 - in head/sys: net netgraph netinet Message-ID: <201511091011.tA9ABFWb029549@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: melifaro Date: Mon Nov 9 10:11:14 2015 New Revision: 290603 URL: https://svnweb.freebsd.org/changeset/base/290603 Log: Use lladdr_event to propagate gratiotus arp. Differential Revision: https://reviews.freebsd.org/D4019 Modified: head/sys/net/if.c head/sys/net/if_vlan.c head/sys/netgraph/ng_eiface.c head/sys/netgraph/ng_ether.c head/sys/netinet/if_ether.c Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Mon Nov 9 09:39:59 2015 (r290602) +++ head/sys/net/if.c Mon Nov 9 10:11:14 2015 (r290603) @@ -2512,7 +2512,8 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, return (error); error = if_setlladdr(ifp, ifr->ifr_addr.sa_data, ifr->ifr_addr.sa_len); - EVENTHANDLER_INVOKE(iflladdr_event, ifp); + if (error == 0) + EVENTHANDLER_INVOKE(iflladdr_event, ifp); break; case SIOCAIFGROUP: @@ -3375,16 +3376,6 @@ if_setlladdr(struct ifnet *ifp, const u_ ifr.ifr_flagshigh = ifp->if_flags >> 16; (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr); } -#ifdef INET - /* - * Also send gratuitous ARPs to notify other nodes about - * the address change. - */ - TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { - if (ifa->ifa_addr->sa_family == AF_INET) - arp_ifinit(ifp, ifa); - } -#endif } return (0); } Modified: head/sys/net/if_vlan.c ============================================================================== --- head/sys/net/if_vlan.c Mon Nov 9 09:39:59 2015 (r290602) +++ head/sys/net/if_vlan.c Mon Nov 9 10:11:14 2015 (r290603) @@ -523,7 +523,7 @@ vlan_iflladdr(void *arg __unused, struct #ifndef VLAN_ARRAY struct ifvlan *next; #endif - int i; + int error, i; /* * Check if it's a trunk interface first of all @@ -544,8 +544,11 @@ vlan_iflladdr(void *arg __unused, struct LIST_FOREACH_SAFE(ifv, &ifp->if_vlantrunk->hash[i], ifv_list, next) { #endif /* VLAN_ARRAY */ VLAN_UNLOCK(); - if_setlladdr(ifv->ifv_ifp, IF_LLADDR(ifp), + error = if_setlladdr(ifv->ifv_ifp, IF_LLADDR(ifp), ifp->if_addrlen); + if (error == 0) + EVENTHANDLER_INVOKE(iflladdr_event, + ifv->ifv_ifp); VLAN_LOCK(); } VLAN_UNLOCK(); Modified: head/sys/netgraph/ng_eiface.c ============================================================================== --- head/sys/netgraph/ng_eiface.c Mon Nov 9 09:39:59 2015 (r290602) +++ head/sys/netgraph/ng_eiface.c Mon Nov 9 10:11:14 2015 (r290603) @@ -489,7 +489,8 @@ ng_eiface_rcvmsg(node_p node, item_p ite } error = if_setlladdr(priv->ifp, (u_char *)msg->data, ETHER_ADDR_LEN); - EVENTHANDLER_INVOKE(iflladdr_event, priv->ifp); + if (error == 0) + EVENTHANDLER_INVOKE(iflladdr_event, priv->ifp); break; } Modified: head/sys/netgraph/ng_ether.c ============================================================================== --- head/sys/netgraph/ng_ether.c Mon Nov 9 09:39:59 2015 (r290602) +++ head/sys/netgraph/ng_ether.c Mon Nov 9 10:11:14 2015 (r290603) @@ -534,7 +534,8 @@ ng_ether_rcvmsg(node_p node, item_p item } error = if_setlladdr(priv->ifp, (u_char *)msg->data, ETHER_ADDR_LEN); - EVENTHANDLER_INVOKE(iflladdr_event, priv->ifp); + if (error == 0) + EVENTHANDLER_INVOKE(iflladdr_event, priv->ifp); break; } case NGM_ETHER_GET_PROMISC: Modified: head/sys/netinet/if_ether.c ============================================================================== --- head/sys/netinet/if_ether.c Mon Nov 9 09:39:59 2015 (r290602) +++ head/sys/netinet/if_ether.c Mon Nov 9 10:11:14 2015 (r290603) @@ -142,7 +142,9 @@ static void in_arpinput(struct mbuf *); static void arp_check_update_lle(struct arphdr *ah, struct in_addr isaddr, struct ifnet *ifp, int bridged, struct llentry *la); static void arp_mark_lle_reachable(struct llentry *la); +static void arp_iflladdr(void *arg __unused, struct ifnet *ifp); +static eventhandler_tag iflladdr_tag; static const struct netisr_handler arp_nh = { .nh_name = "arp", @@ -1150,10 +1152,39 @@ arp_ifinit2(struct ifnet *ifp, struct if ifa->ifa_rtrequest = NULL; } +/* + * Sends gratuitous ARPs for each ifaddr to notify other + * nodes about the address change. + */ +static __noinline void +arp_handle_ifllchange(struct ifnet *ifp) +{ + struct ifaddr *ifa; + + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { + if (ifa->ifa_addr->sa_family == AF_INET) + arp_ifinit(ifp, ifa); + } +} + +/* + * A handler for interface link layer address change event. + */ +static __noinline void +arp_iflladdr(void *arg __unused, struct ifnet *ifp) +{ + + if ((ifp->if_flags & IFF_UP) != 0) + arp_handle_ifllchange(ifp); +} + static void arp_init(void) { netisr_register(&arp_nh); + if (IS_DEFAULT_VNET(curvnet)) + iflladdr_tag = EVENTHANDLER_REGISTER(iflladdr_event, + arp_iflladdr, NULL, EVENTHANDLER_PRI_ANY); } SYSINIT(arp, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY, arp_init, 0);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511091011.tA9ABFWb029549>