svn commit: r195643 - head/sys/netinet6
Author: qingli Date: Sun Jul 12 19:20:55 2009 New Revision: 195643 URL: http://svn.freebsd.org/changeset/base/195643 Log: This patch adds a host route to an interface address (that is assigned to a non loopback/ppp link type) through the loopback interface. Prior to the new L2/L3 rewrite, this host route was explicitly created when processing the IPv6 address assignment. This loopback host route is deleted when that IPv6 address is removed from the interface. Reviewed by: bz, gnn Approved by: re Modified: head/sys/netinet6/in6.c Modified: head/sys/netinet6/in6.c == --- head/sys/netinet6/in6.c Sun Jul 12 17:07:35 2009(r195642) +++ head/sys/netinet6/in6.c Sun Jul 12 19:20:55 2009(r195643) @@ -1194,6 +1194,25 @@ in6_purgeaddr(struct ifaddr *ifa) ifa_ref(ifa0); IF_ADDR_UNLOCK(ifp); + if (!(ia-ia_ifp-if_flags (IFF_LOOPBACK | IFF_POINTOPOINT))) { + struct rt_addrinfo info; + struct sockaddr_dl null_sdl; + + bzero(null_sdl, sizeof(null_sdl)); + null_sdl.sdl_len = sizeof(null_sdl); + null_sdl.sdl_family = AF_LINK; + null_sdl.sdl_type = V_loif-if_type; + null_sdl.sdl_index = V_loif-if_index; + bzero(info, sizeof(info)); + info.rti_flags = ia-ia_flags | RTF_HOST | RTF_STATIC; + info.rti_info[RTAX_DST] = (struct sockaddr *)ia-ia_addr; + info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)null_sdl; + error = rtrequest1_fib(RTM_DELETE, info, NULL, 0); + + if (error != 0) + log(LOG_INFO, in6_purgeaddr: deletion failed\n); + } + /* stop DAD processing */ nd6_dad_stop(ifa); @@ -1755,6 +1774,33 @@ in6_ifinit(struct ifnet *ifp, struct in6 ia-ia_flags |= IFA_ROUTE; } + /* +* add a loopback route to self +*/ + if (!(ifp-if_flags (IFF_LOOPBACK | IFF_POINTOPOINT))) { + struct rt_addrinfo info; + struct rtentry *rt = NULL; + static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK}; + + bzero(info, sizeof(info)); + info.rti_ifp = V_loif; + info.rti_flags = ia-ia_flags | RTF_HOST | RTF_STATIC; + info.rti_info[RTAX_DST] = (struct sockaddr *)ia-ia_addr; + info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)null_sdl; + error = rtrequest1_fib(RTM_ADD, info, rt, 0); + + if (error == 0 rt != NULL) { + RT_LOCK(rt); + ((struct sockaddr_dl *)rt-rt_gateway)-sdl_type = + rt-rt_ifp-if_type; + ((struct sockaddr_dl *)rt-rt_gateway)-sdl_index = + rt-rt_ifp-if_index; + RT_REMREF(rt); + RT_UNLOCK(rt); + } else if (error != 0) + log(LOG_INFO, in6_ifinit: insertion failed\n); + } + /* Add ownaddr as loopback rtentry, if necessary (ex. on p2p link). */ if (newhost) { struct llentry *ln; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r195914 - in head/sys: net netinet netinet6
Author: qingli Date: Mon Jul 27 17:08:06 2009 New Revision: 195914 URL: http://svn.freebsd.org/changeset/base/195914 Log: This patch does the following: - Allow loopback route to be installed for address assigned to interface of IFF_POINTOPOINT type. - Install loopback route for an IPv4 interface addreess when the useloopback sysctl variable is enabled. Similarly, install loopback route for an IPv6 interface address when the sysctl variable nd6_useloopback is enabled. Deleting loopback routes for interface addresses is unconditional in case these sysctl variables were disabled after an interface address has been assigned. Reviewed by: bz Approved by: re Modified: head/sys/net/if_var.h head/sys/netinet/if_ether.c head/sys/netinet/in.c head/sys/netinet6/in6.c Modified: head/sys/net/if_var.h == --- head/sys/net/if_var.h Mon Jul 27 16:11:44 2009(r195913) +++ head/sys/net/if_var.h Mon Jul 27 17:08:06 2009(r195914) @@ -784,11 +784,13 @@ VNET_DECLARE(struct ifnethead, ifnet); VNET_DECLARE(struct ifgrouphead, ifg_head); VNET_DECLARE(int, if_index); VNET_DECLARE(struct ifnet *, loif);/* first loopback interface */ +VNET_DECLARE(int, useloopback); #defineV_ifnet VNET(ifnet) #defineV_ifg_head VNET(ifg_head) #defineV_if_index VNET(if_index) #defineV_loif VNET(loif) +#defineV_useloopback VNET(useloopback) extern int ifqmaxlen; Modified: head/sys/netinet/if_ether.c == --- head/sys/netinet/if_ether.c Mon Jul 27 16:11:44 2009(r195913) +++ head/sys/netinet/if_ether.c Mon Jul 27 17:08:06 2009(r195914) @@ -81,17 +81,17 @@ __FBSDID($FreeBSD$); SYSCTL_DECL(_net_link_ether); SYSCTL_NODE(_net_link_ether, PF_INET, inet, CTLFLAG_RW, 0, ); +VNET_DEFINE(int, useloopback) = 1; /* use loopback interface for +* local traffic */ + /* timer values */ static VNET_DEFINE(int, arpt_keep) = (20*60); /* once resolved, good for 20 * minutes */ static VNET_DEFINE(int, arp_maxtries) = 5; -static VNET_DEFINE(int, useloopback) = 1; /* use loopback interface for -* local traffic */ static VNET_DEFINE(int, arp_proxyall); #defineV_arpt_keep VNET(arpt_keep) #defineV_arp_maxtries VNET(arp_maxtries) -#defineV_useloopback VNET(useloopback) #defineV_arp_proxyall VNET(arp_proxyall) SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, max_age, CTLFLAG_RW, Modified: head/sys/netinet/in.c == --- head/sys/netinet/in.c Mon Jul 27 16:11:44 2009(r195913) +++ head/sys/netinet/in.c Mon Jul 27 17:08:06 2009(r195914) @@ -49,6 +49,7 @@ __FBSDID($FreeBSD$); #include sys/vimage.h #include net/if.h +#include net/if_var.h #include net/if_dl.h #include net/if_llatbl.h #include net/if_types.h @@ -918,7 +919,7 @@ in_ifinit(struct ifnet *ifp, struct in_i /* * add a loopback route to self */ - if (!(ifp-if_flags (IFF_LOOPBACK | IFF_POINTOPOINT))) { + if (V_useloopback !(ifp-if_flags IFF_LOOPBACK)) { bzero(info, sizeof(info)); info.rti_ifp = V_loif; info.rti_flags = ia-ia_flags | RTF_HOST | RTF_STATIC; @@ -1027,8 +1028,18 @@ in_scrubprefix(struct in_ifaddr *target) if ((target-ia_flags IFA_ROUTE) == 0) return (0); + /* +* Remove the loopback route to the interface address. +* The useloopback setting is not consulted because if the +* user configures an interface address, turns off this +* setting, and then tries to delete that interface address, +* checking the current setting of useloopback would leave +* that interface address loopback route untouched, which +* would be wrong. Therefore the interface address loopback route +* deletion is unconditional. +*/ if ((target-ia_addr.sin_addr.s_addr != INADDR_ANY) - !(target-ia_ifp-if_flags (IFF_LOOPBACK | IFF_POINTOPOINT))) { + !(target-ia_ifp-if_flags IFF_LOOPBACK)) { bzero(null_sdl, sizeof(null_sdl)); null_sdl.sdl_len = sizeof(null_sdl); null_sdl.sdl_family = AF_LINK; Modified: head/sys/netinet6/in6.c == --- head/sys/netinet6/in6.c Mon Jul 27 16:11:44 2009(r195913) +++ head/sys/netinet6/in6.c Mon Jul 27 17:08:06 2009(r195914) @@ -1191,7 +1191,11 @@
svn commit: r195921 - head/sys/net
Author: qingli Date: Tue Jul 28 17:16:54 2009 New Revision: 195921 URL: http://svn.freebsd.org/changeset/base/195921 Log: The new flow table caches both the routing table entry as well as the L2 information. For an indirect route the cached L2 entry contains the MAC address of the gateway. Typically the default route is used to transmit multicast packets when explicit multicast routes are not available. The ether_output() function bypasses L2 resolution function if it verifies the L2 cache is valid, because the cached L2 address (a unicast MAC address) is copied into the packets as the destination MAC address. This validation, however, does not apply to broadcast and multicast packets because the destination MAC address is mapped according to a standard method instead. Submitted by: Xin Li Reviewed by: bz Approved by: re Modified: head/sys/net/if_ethersubr.c Modified: head/sys/net/if_ethersubr.c == --- head/sys/net/if_ethersubr.c Tue Jul 28 15:57:53 2009(r195920) +++ head/sys/net/if_ethersubr.c Tue Jul 28 17:16:54 2009(r195921) @@ -174,7 +174,8 @@ ether_output(struct ifnet *ifp, struct m int hlen; /* link layer header length */ if (ro != NULL) { - lle = ro-ro_lle; + if (!(m-m_flags (M_BCAST | M_MCAST))) + lle = ro-ro_lle; rt0 = ro-ro_rt; } #ifdef MAC ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r196152 - head/sys/netinet6
Author: qingli Date: Wed Aug 12 19:15:26 2009 New Revision: 196152 URL: http://svn.freebsd.org/changeset/base/196152 Log: A piece of code was added to install a host route when an IPv6 interface address is configured with a /128 prefix. This is no longer necessary due to r192011. In fact that code conflicts with r192011. This patch removes the host route installation when detecting the /128 prefix, and instead let the code added by r192011 to install the loopback route for that IPv6 interface address. Reviewed by: bz Approved by: re Modified: head/sys/netinet6/in6.c Modified: head/sys/netinet6/in6.c == --- head/sys/netinet6/in6.c Wed Aug 12 17:45:55 2009(r196151) +++ head/sys/netinet6/in6.c Wed Aug 12 19:15:26 2009(r196152) @@ -1750,21 +1750,12 @@ in6_ifinit(struct ifnet *ifp, struct in6 * interface that share the same destination. */ plen = in6_mask2len(ia-ia_prefixmask.sin6_addr, NULL); /* XXX */ - if (!(ia-ia_flags IFA_ROUTE) plen == 128) { - struct sockaddr *dstaddr; + if (!(ia-ia_flags IFA_ROUTE) plen == 128 + ia-ia_dstaddr.sin6_family == AF_INET6) { int rtflags = RTF_UP | RTF_HOST; - /* -* use the interface address if configuring an -* interface address with a /128 prefix len -*/ - if (ia-ia_dstaddr.sin6_family == AF_INET6) - dstaddr = (struct sockaddr *)ia-ia_dstaddr; - else - dstaddr = (struct sockaddr *)ia-ia_addr; - error = rtrequest(RTM_ADD, - (struct sockaddr *)dstaddr, + (struct sockaddr *)ia-ia_dstaddr, (struct sockaddr *)ia-ia_addr, (struct sockaddr *)ia-ia_prefixmask, ia-ia_flags | rtflags, NULL); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r196154 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/ata dev/cxgb dev/sound/usb dev/usb dev/usb/controller dev/usb/input dev/usb/mis...
Author: qingli Date: Wed Aug 12 20:48:50 2009 New Revision: 196154 URL: http://svn.freebsd.org/changeset/base/196154 Log: MFC r196152 A piece of code was added to install a host route when an IPv6 interface address is configured with a /128 prefix. This is no longer necessary due to r192011. In fact that code conflicts with r192011. This patch removes the host route installation when detecting the /128 prefix, and instead let the code added by r192011 to install the loopback route for that IPv6 interface address. Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/ata/ (props changed) stable/8/sys/dev/ata/ata-usb.c (props changed) stable/8/sys/dev/cxgb/ (props changed) stable/8/sys/dev/sound/usb/uaudio.c (props changed) stable/8/sys/dev/sound/usb/uaudio.h (props changed) stable/8/sys/dev/sound/usb/uaudio_pcm.c (props changed) stable/8/sys/dev/sound/usb/uaudioreg.h (props changed) stable/8/sys/dev/usb/controller/at91dci.c (props changed) stable/8/sys/dev/usb/controller/at91dci.h (props changed) stable/8/sys/dev/usb/controller/at91dci_atmelarm.c (props changed) stable/8/sys/dev/usb/controller/atmegadci.c (props changed) stable/8/sys/dev/usb/controller/atmegadci.h (props changed) stable/8/sys/dev/usb/controller/atmegadci_atmelarm.c (props changed) stable/8/sys/dev/usb/controller/ehci.c (props changed) stable/8/sys/dev/usb/controller/ehci.h (props changed) stable/8/sys/dev/usb/controller/ehci_ixp4xx.c (props changed) stable/8/sys/dev/usb/controller/ehci_mbus.c (props changed) stable/8/sys/dev/usb/controller/ehci_pci.c (props changed) stable/8/sys/dev/usb/controller/musb_otg.c (props changed) stable/8/sys/dev/usb/controller/musb_otg.h (props changed) stable/8/sys/dev/usb/controller/musb_otg_atmelarm.c (props changed) stable/8/sys/dev/usb/controller/ohci.c (props changed) stable/8/sys/dev/usb/controller/ohci.h (props changed) stable/8/sys/dev/usb/controller/ohci_atmelarm.c (props changed) stable/8/sys/dev/usb/controller/ohci_pci.c (props changed) stable/8/sys/dev/usb/controller/uhci.c (props changed) stable/8/sys/dev/usb/controller/uhci.h (props changed) stable/8/sys/dev/usb/controller/uhci_pci.c (props changed) stable/8/sys/dev/usb/controller/usb_controller.c (props changed) stable/8/sys/dev/usb/controller/uss820dci.c (props changed) stable/8/sys/dev/usb/controller/uss820dci.h (props changed) stable/8/sys/dev/usb/controller/uss820dci_atmelarm.c (props changed) stable/8/sys/dev/usb/input/uhid.c (props changed) stable/8/sys/dev/usb/input/ukbd.c (props changed) stable/8/sys/dev/usb/input/ums.c (props changed) stable/8/sys/dev/usb/input/usb_rdesc.h (props changed) stable/8/sys/dev/usb/misc/udbp.c (props changed) stable/8/sys/dev/usb/misc/udbp.h (props changed) stable/8/sys/dev/usb/misc/ufm.c (props changed) stable/8/sys/dev/usb/net/if_aue.c (props changed) stable/8/sys/dev/usb/net/if_auereg.h (props changed) stable/8/sys/dev/usb/net/if_axe.c (props changed) stable/8/sys/dev/usb/net/if_axereg.h (props changed) stable/8/sys/dev/usb/net/if_cdce.c (props changed) stable/8/sys/dev/usb/net/if_cdcereg.h (props changed) stable/8/sys/dev/usb/net/if_cue.c (props changed) stable/8/sys/dev/usb/net/if_cuereg.h (props changed) stable/8/sys/dev/usb/net/if_kue.c (props changed) stable/8/sys/dev/usb/net/if_kuefw.h (props changed) stable/8/sys/dev/usb/net/if_kuereg.h (props changed) stable/8/sys/dev/usb/net/if_rue.c (props changed) stable/8/sys/dev/usb/net/if_ruereg.h (props changed) stable/8/sys/dev/usb/net/if_udav.c (props changed) stable/8/sys/dev/usb/net/if_udavreg.h (props changed) stable/8/sys/dev/usb/net/usb_ethernet.c (props changed) stable/8/sys/dev/usb/net/usb_ethernet.h (props changed) stable/8/sys/dev/usb/quirk/usb_quirk.c (props changed) stable/8/sys/dev/usb/quirk/usb_quirk.h (props changed) stable/8/sys/dev/usb/serial/u3g.c (props changed) stable/8/sys/dev/usb/serial/uark.c (props changed) stable/8/sys/dev/usb/serial/ubsa.c (props changed) stable/8/sys/dev/usb/serial/ubser.c (props changed) stable/8/sys/dev/usb/serial/uchcom.c (props changed) stable/8/sys/dev/usb/serial/ucycom.c (props changed) stable/8/sys/dev/usb/serial/ufoma.c (props changed) stable/8/sys/dev/usb/serial/uftdi.c (props changed) stable/8/sys/dev/usb/serial/uftdi_reg.h (props changed) stable/8/sys/dev/usb/serial/ugensa.c (props changed) stable/8/sys/dev/usb/serial/uipaq.c (props changed) stable/8/sys/dev/usb/serial/ulpt.c (props changed) stable/8/sys/dev/usb/serial/umct.c (props changed)
svn commit: r196234 - head/sys/netinet
Author: qingli Date: Fri Aug 14 23:44:59 2009 New Revision: 196234 URL: http://svn.freebsd.org/changeset/base/196234 Log: In function ip_output(), the cached route is flushed when there is a mismatch between the cached entry and the intended destination. The cached rtentry{} is flushed but the associated llentry{} is not. This causes the wrong destination MAC address being used in the output packets. The fix is to flush the llentry{} when rtentry{} is cleared. Reviewed by: kmacy, rwatson Approved by: re Modified: head/sys/netinet/ip_output.c Modified: head/sys/netinet/ip_output.c == --- head/sys/netinet/ip_output.cFri Aug 14 23:05:10 2009 (r196233) +++ head/sys/netinet/ip_output.cFri Aug 14 23:44:59 2009 (r196234) @@ -53,6 +53,7 @@ __FBSDID($FreeBSD$); #include sys/ucred.h #include net/if.h +#include net/if_llatbl.h #include net/netisr.h #include net/pfil.h #include net/route.h @@ -201,9 +202,12 @@ again: if (ro-ro_rt ((ro-ro_rt-rt_flags RTF_UP) == 0 || dst-sin_family != AF_INET || dst-sin_addr.s_addr != ip-ip_dst.s_addr)) { - if (!nortfree) + if (!nortfree) { RTFREE(ro-ro_rt); + LLE_FREE(ro-ro_lle); + } ro-ro_rt = (struct rtentry *)NULL; + ro-ro_lle = (struct llentry *)NULL; } #ifdef IPFIREWALL_FORWARD if (ro-ro_rt == NULL fwd_tag == NULL) { ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r196235 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/ata dev/cxgb dev/xen/netfront dev/xen/xenpci modules/dtrace/dtnfsclient modules...
Author: qingli Date: Sat Aug 15 00:04:12 2009 New Revision: 196235 URL: http://svn.freebsd.org/changeset/base/196235 Log: MFC 196234 In function ip_output(), the cached route is flushed when there is a mismatch between the cached entry and the intended destination. The cached rtentry{} is flushed but the associated llentry{} is not. This causes the wrong destination MAC address being used in the output packets. The fix is to flush the llentry{} when rtentry{} is cleared. Reviewed by: kmacy, rwatson Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/ata/ (props changed) stable/8/sys/dev/cxgb/ (props changed) stable/8/sys/dev/xen/netfront/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/modules/dtrace/dtnfsclient/ (props changed) stable/8/sys/modules/ip6_mroute_mod/ (props changed) stable/8/sys/modules/ipmi/ipmi_linux/ (props changed) stable/8/sys/netinet/ip_output.c stable/8/sys/netinet/ipfw/ip_dummynet.c (props changed) stable/8/sys/netinet/ipfw/ip_fw2.c (props changed) stable/8/sys/netinet/ipfw/ip_fw_nat.c (props changed) stable/8/sys/netinet/ipfw/ip_fw_pfil.c (props changed) stable/8/sys/netipx/spx_reass.c (props changed) stable/8/sys/xen/evtchn.h (props changed) stable/8/sys/xen/hypervisor.h (props changed) stable/8/sys/xen/xen_intr.h (props changed) Modified: stable/8/sys/netinet/ip_output.c == --- stable/8/sys/netinet/ip_output.cFri Aug 14 23:44:59 2009 (r196234) +++ stable/8/sys/netinet/ip_output.cSat Aug 15 00:04:12 2009 (r196235) @@ -53,6 +53,7 @@ __FBSDID($FreeBSD$); #include sys/ucred.h #include net/if.h +#include net/if_llatbl.h #include net/netisr.h #include net/pfil.h #include net/route.h @@ -201,9 +202,12 @@ again: if (ro-ro_rt ((ro-ro_rt-rt_flags RTF_UP) == 0 || dst-sin_family != AF_INET || dst-sin_addr.s_addr != ip-ip_dst.s_addr)) { - if (!nortfree) + if (!nortfree) { RTFREE(ro-ro_rt); + LLE_FREE(ro-ro_lle); + } ro-ro_rt = (struct rtentry *)NULL; + ro-ro_lle = (struct llentry *)NULL; } #ifdef IPFIREWALL_FORWARD if (ro-ro_rt == NULL fwd_tag == NULL) { ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r196569 - head/sys/netinet6
Author: qingli Date: Wed Aug 26 21:32:50 2009 New Revision: 196569 URL: http://svn.freebsd.org/changeset/base/196569 Log: When multiple interfaces exist in the system, with each interface having an IPv6 address assigned to it, and if an incoming packet received on one interface has a packet destination address that belongs to another interface, the routing table is consulted to determine how to reach this packet destination. Since the packet destination is an interface address, the route table will return a host route with the loopback interface as rt_ifp. The input code must recognize this fact, instead of using the loopback interface, the input code performs a search to find the right interface that owns the given IPv6 address. Reviewed by: bz, gnn, kmacy MFC after:immediately Modified: head/sys/netinet6/ip6_input.c Modified: head/sys/netinet6/ip6_input.c == --- head/sys/netinet6/ip6_input.c Wed Aug 26 21:14:28 2009 (r196568) +++ head/sys/netinet6/ip6_input.c Wed Aug 26 21:32:50 2009 (r196569) @@ -628,8 +628,27 @@ passin: rt6_key(rin6.ro_rt)-sin6_addr) #endif rin6.ro_rt-rt_ifp-if_type == IFT_LOOP) { - struct in6_ifaddr *ia6 = - (struct in6_ifaddr *)rin6.ro_rt-rt_ifa; + int free_ia6 = 0; + struct in6_ifaddr *ia6; + + /* +* found the loopback route to the interface address +*/ + if (rin6.ro_rt-rt_gateway-sa_family == AF_LINK) { + struct sockaddr_in6 dest6; + + bzero(dest6, sizeof(dest6)); + dest6.sin6_family = AF_INET6; + dest6.sin6_len = sizeof(dest6); + dest6.sin6_addr = ip6-ip6_dst; + ia6 = (struct in6_ifaddr *) + ifa_ifwithaddr((struct sockaddr *)dest6); + if (ia6 == NULL) + goto bad; + free_ia6 = 1; + } + else + ia6 = (struct in6_ifaddr *)rin6.ro_rt-rt_ifa; /* * record address information into m_tag. @@ -647,6 +666,8 @@ passin: /* Count the packet in the ip address stats */ ia6-ia_ifa.if_ipackets++; ia6-ia_ifa.if_ibytes += m-m_pkthdr.len; + if (ia6 != NULL free_ia6 != 0) + ifa_free(ia6-ia_ifa); goto hbhcheck; } else { char ip6bufs[INET6_ADDRSTRLEN]; @@ -657,6 +678,8 @@ passin: ip6_sprintf(ip6bufs, ip6-ip6_src), ip6_sprintf(ip6bufd, ip6-ip6_dst))); + if (ia6 != NULL free_ia6 != 0) + ifa_free(ia6-ia_ifa); goto bad; } } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r196609 - head/sys/net
Author: qingli Date: Fri Aug 28 07:01:09 2009 New Revision: 196609 URL: http://svn.freebsd.org/changeset/base/196609 Log: In ip_output(), the flow-table module must not try to cache L2/L3 information for interface of IFF_POINTOPOINT or IFF_LOOPBACK type. Since the L2 information (rt_lle) is invalid for these interface types, accidental caching attempt will trigger panic when the invalid rt_lle reference is accessed. When installing a new route, or when updating an existing route, the user supplied gateway address may be an interface address (this is particularly true for point-to-point interface related modules such as ppp, if_tun, if_gif). Currently the routing command handler always set the RTF_GATEWAY flag if the gateway address is given as part of the command paramters. Therefore the gateway address must be verified against interface addresses or else the route would be treated as an indirect route, thus making that route unusable. Reviewed by: kmacy, julia, rwatson Verified by: marcus MFC after:3 days Modified: head/sys/net/flowtable.c head/sys/net/rtsock.c Modified: head/sys/net/flowtable.c == --- head/sys/net/flowtable.cFri Aug 28 05:37:31 2009(r196608) +++ head/sys/net/flowtable.cFri Aug 28 07:01:09 2009(r196609) @@ -692,6 +692,12 @@ uncached: struct rtentry *rt = ro-ro_rt; struct ifnet *ifp = rt-rt_ifp; + if (ifp-if_flags (IFF_POINTOPOINT | IFF_LOOPBACK)) { + RTFREE(rt); + ro-ro_rt = NULL; + return (ENOENT); + } + if (rt-rt_flags RTF_GATEWAY) l3addr = rt-rt_gateway; else Modified: head/sys/net/rtsock.c == --- head/sys/net/rtsock.c Fri Aug 28 05:37:31 2009(r196608) +++ head/sys/net/rtsock.c Fri Aug 28 07:01:09 2009(r196609) @@ -513,6 +513,39 @@ route_output(struct mbuf *m, struct sock senderr(error); } + /* +* The given gateway address may be an interface address. +* For example, issuing a route change command on a route +* entry that was created from a tunnel, and the gateway +* address given is the local end point. In this case the +* RTF_GATEWAY flag must be cleared or the destination will +* not be reachable even though there is no error message. +*/ + if (info.rti_info[RTAX_GATEWAY] != NULL + info.rti_info[RTAX_GATEWAY]-sa_family != AF_LINK) { + struct route gw_ro; + + bzero(gw_ro, sizeof(gw_ro)); + gw_ro.ro_dst = *info.rti_info[RTAX_GATEWAY]; + rtalloc_ign(gw_ro, 0); + /* +* A host route through the loopback interface is +* installed for each interface adddress. In pre 8.0 +* releases the interface address of a PPP link type +* is not reachable locally. This behavior is fixed as +* part of the new L2/L3 redesign and rewrite work. The +* signature of this interface address route is the +* AF_LINK sa_family type of the rt_gateway, and the +* rt_ifp has the IFF_LOOPBACK flag set. +*/ + if (gw_ro.ro_rt != NULL + gw_ro.ro_rt-rt_gateway-sa_family == AF_LINK + gw_ro.ro_rt-rt_ifp-if_flags IFF_LOOPBACK) + info.rti_flags = ~RTF_GATEWAY; + if (gw_ro.ro_rt != NULL) + RTFREE(gw_ro.ro_rt); + } + switch (rtm-rtm_type) { struct rtentry *saved_nrt; @@ -714,7 +747,7 @@ route_output(struct mbuf *m, struct sock RT_UNLOCK(rt); senderr(error); } - rt-rt_flags |= RTF_GATEWAY; + rt-rt_flags |= (RTF_GATEWAY info.rti_flags); } if (info.rti_ifa != NULL info.rti_ifa != rt-rt_ifa) { ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r196671 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet6
Author: qingli Date: Sun Aug 30 22:36:46 2009 New Revision: 196671 URL: http://svn.freebsd.org/changeset/base/196671 Log: MFC r196569 When multiple interfaces exist in the system, with each interface having an IPv6 address assigned to it, and if an incoming packet received on one interface has a packet destination address that belongs to another interface, the routing table is consulted to determine how to reach this packet destination. Since the packet destination is an interface address, the route table will return a host route with the loopback interface as rt_ifp. The input code must recognize this fact, instead of using the loopback interface, the input code performs a search to find the right interface that owns the given IPv6 address. Reviewed by: bz, gnn, kmacy Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet6/ip6_input.c Modified: stable/8/sys/netinet6/ip6_input.c == --- stable/8/sys/netinet6/ip6_input.c Sun Aug 30 22:35:20 2009 (r196670) +++ stable/8/sys/netinet6/ip6_input.c Sun Aug 30 22:36:46 2009 (r196671) @@ -628,8 +628,27 @@ passin: rt6_key(rin6.ro_rt)-sin6_addr) #endif rin6.ro_rt-rt_ifp-if_type == IFT_LOOP) { - struct in6_ifaddr *ia6 = - (struct in6_ifaddr *)rin6.ro_rt-rt_ifa; + int free_ia6 = 0; + struct in6_ifaddr *ia6; + + /* +* found the loopback route to the interface address +*/ + if (rin6.ro_rt-rt_gateway-sa_family == AF_LINK) { + struct sockaddr_in6 dest6; + + bzero(dest6, sizeof(dest6)); + dest6.sin6_family = AF_INET6; + dest6.sin6_len = sizeof(dest6); + dest6.sin6_addr = ip6-ip6_dst; + ia6 = (struct in6_ifaddr *) + ifa_ifwithaddr((struct sockaddr *)dest6); + if (ia6 == NULL) + goto bad; + free_ia6 = 1; + } + else + ia6 = (struct in6_ifaddr *)rin6.ro_rt-rt_ifa; /* * record address information into m_tag. @@ -647,6 +666,8 @@ passin: /* Count the packet in the ip address stats */ ia6-ia_ifa.if_ipackets++; ia6-ia_ifa.if_ibytes += m-m_pkthdr.len; + if (ia6 != NULL free_ia6 != 0) + ifa_free(ia6-ia_ifa); goto hbhcheck; } else { char ip6bufs[INET6_ADDRSTRLEN]; @@ -657,6 +678,8 @@ passin: ip6_sprintf(ip6bufs, ip6-ip6_src), ip6_sprintf(ip6bufd, ip6-ip6_dst))); + if (ia6 != NULL free_ia6 != 0) + ifa_free(ia6-ia_ifa); goto bad; } } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r196672 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet
Author: qingli Date: Sun Aug 30 22:39:49 2009 New Revision: 196672 URL: http://svn.freebsd.org/changeset/base/196672 Log: MFC r196608 Do not try to free the rt_lle entry of the cached route in ip_output() if the cached route was not initialized from the flow-table. The rt_lle entry is invalid unless it has been initialized through the flow-table. Reviewed by: kmacy, rwatson Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet/ip_output.c Modified: stable/8/sys/netinet/ip_output.c == --- stable/8/sys/netinet/ip_output.cSun Aug 30 22:36:46 2009 (r196671) +++ stable/8/sys/netinet/ip_output.cSun Aug 30 22:39:49 2009 (r196672) @@ -202,10 +202,8 @@ again: if (ro-ro_rt ((ro-ro_rt-rt_flags RTF_UP) == 0 || dst-sin_family != AF_INET || dst-sin_addr.s_addr != ip-ip_dst.s_addr)) { - if (!nortfree) { + if (!nortfree) RTFREE(ro-ro_rt); - LLE_FREE(ro-ro_lle); - } ro-ro_rt = (struct rtentry *)NULL; ro-ro_lle = (struct llentry *)NULL; } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r196673 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net
Author: qingli Date: Sun Aug 30 22:42:32 2009 New Revision: 196673 URL: http://svn.freebsd.org/changeset/base/196673 Log: MFC r196609 In ip_output(), the flow-table module must not try to cache L2/L3 information for interface of IFF_POINTOPOINT or IFF_LOOPBACK type. Since the L2 information (rt_lle) is invalid for these interface types, accidental caching attempt will trigger panic when the invalid rt_lle reference is accessed. When installing a new route, or when updating an existing route, the user supplied gateway address may be an interface address (this is particularly true for point-to-point interface related modules such as ppp, if_tun, if_gif). Currently the routing command handler always set the RTF_GATEWAY flag if the gateway address is given as part of the command paramters. Therefore the gateway address must be verified against interface addresses or else the route would be treated as an indirect route, thus making that route unusable. Reviewed by: kmacy, julian, rwatson Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/flowtable.c stable/8/sys/net/rtsock.c Modified: stable/8/sys/net/flowtable.c == --- stable/8/sys/net/flowtable.cSun Aug 30 22:39:49 2009 (r196672) +++ stable/8/sys/net/flowtable.cSun Aug 30 22:42:32 2009 (r196673) @@ -692,6 +692,12 @@ uncached: struct rtentry *rt = ro-ro_rt; struct ifnet *ifp = rt-rt_ifp; + if (ifp-if_flags (IFF_POINTOPOINT | IFF_LOOPBACK)) { + RTFREE(rt); + ro-ro_rt = NULL; + return (ENOENT); + } + if (rt-rt_flags RTF_GATEWAY) l3addr = rt-rt_gateway; else Modified: stable/8/sys/net/rtsock.c == --- stable/8/sys/net/rtsock.c Sun Aug 30 22:39:49 2009(r196672) +++ stable/8/sys/net/rtsock.c Sun Aug 30 22:42:32 2009(r196673) @@ -513,6 +513,39 @@ route_output(struct mbuf *m, struct sock senderr(error); } + /* +* The given gateway address may be an interface address. +* For example, issuing a route change command on a route +* entry that was created from a tunnel, and the gateway +* address given is the local end point. In this case the +* RTF_GATEWAY flag must be cleared or the destination will +* not be reachable even though there is no error message. +*/ + if (info.rti_info[RTAX_GATEWAY] != NULL + info.rti_info[RTAX_GATEWAY]-sa_family != AF_LINK) { + struct route gw_ro; + + bzero(gw_ro, sizeof(gw_ro)); + gw_ro.ro_dst = *info.rti_info[RTAX_GATEWAY]; + rtalloc_ign(gw_ro, 0); + /* +* A host route through the loopback interface is +* installed for each interface adddress. In pre 8.0 +* releases the interface address of a PPP link type +* is not reachable locally. This behavior is fixed as +* part of the new L2/L3 redesign and rewrite work. The +* signature of this interface address route is the +* AF_LINK sa_family type of the rt_gateway, and the +* rt_ifp has the IFF_LOOPBACK flag set. +*/ + if (gw_ro.ro_rt != NULL + gw_ro.ro_rt-rt_gateway-sa_family == AF_LINK + gw_ro.ro_rt-rt_ifp-if_flags IFF_LOOPBACK) + info.rti_flags = ~RTF_GATEWAY; + if (gw_ro.ro_rt != NULL) + RTFREE(gw_ro.ro_rt); + } + switch (rtm-rtm_type) { struct rtentry *saved_nrt; @@ -714,7 +747,7 @@ route_output(struct mbuf *m, struct sock RT_UNLOCK(rt); senderr(error); } - rt-rt_flags |= RTF_GATEWAY; + rt-rt_flags |= (RTF_GATEWAY info.rti_flags); } if (info.rti_ifa != NULL info.rti_ifa != rt-rt_ifa) { ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r196674 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet6
Author: qingli Date: Sun Aug 30 22:44:12 2009 New Revision: 196674 URL: http://svn.freebsd.org/changeset/base/196674 Log: MFC r196649 Prefix on-link verification is being performed on statically configured prefixes. Since these statically configured prefixes do not have any associated advertising routers, these prefixes are treated as unreachable and those prefix routes are deleted from the routing table. Therefore bypass prefixes that are not learned from router advertisements during prefix on-link check. Reviewed by: hrs Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet6/nd6_rtr.c Modified: stable/8/sys/netinet6/nd6_rtr.c == --- stable/8/sys/netinet6/nd6_rtr.c Sun Aug 30 22:42:32 2009 (r196673) +++ stable/8/sys/netinet6/nd6_rtr.c Sun Aug 30 22:44:12 2009 (r196674) @@ -1415,6 +1415,9 @@ pfxlist_onlink_check() if (pr-ndpr_raf_onlink == 0) continue; + if (pr-ndpr_raf_auto == 0) + continue; + if ((pr-ndpr_stateflags NDPRF_DETACHED) == 0 find_pfxlist_reachable_router(pr) == NULL) pr-ndpr_stateflags |= NDPRF_DETACHED; @@ -1431,6 +1434,9 @@ pfxlist_onlink_check() if (pr-ndpr_raf_onlink == 0) continue; + if (pr-ndpr_raf_auto == 0) + continue; + if ((pr-ndpr_stateflags NDPRF_DETACHED) != 0) pr-ndpr_stateflags = ~NDPRF_DETACHED; } @@ -1454,6 +1460,9 @@ pfxlist_onlink_check() if (pr-ndpr_raf_onlink == 0) continue; + if (pr-ndpr_raf_auto == 0) + continue; + if ((pr-ndpr_stateflags NDPRF_DETACHED) != 0 (pr-ndpr_stateflags NDPRF_ONLINK) != 0) { if ((e = nd6_prefix_offlink(pr)) != 0) { ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r196679 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net
Author: qingli Date: Mon Aug 31 00:18:17 2009 New Revision: 196679 URL: http://svn.freebsd.org/changeset/base/196679 Log: As part of r196609, a call to rtalloc did not take the fib into account. So call the appropriate rtalloc_ign_fib() instead of calling rtalloc_ign(). Reviewed by: pointed out by bz Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/rtsock.c Modified: stable/8/sys/net/rtsock.c == --- stable/8/sys/net/rtsock.c Mon Aug 31 00:14:37 2009(r196678) +++ stable/8/sys/net/rtsock.c Mon Aug 31 00:18:17 2009(r196679) @@ -527,7 +527,7 @@ route_output(struct mbuf *m, struct sock bzero(gw_ro, sizeof(gw_ro)); gw_ro.ro_dst = *info.rti_info[RTAX_GATEWAY]; - rtalloc_ign(gw_ro, 0); + rtalloc_ign_fib(gw_ro, 0, so-so_fibnum); /* * A host route through the loopback interface is * installed for each interface adddress. In pre 8.0 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r196678 - head/sys/net
Author: qingli Date: Mon Aug 31 00:14:37 2009 New Revision: 196678 URL: http://svn.freebsd.org/changeset/base/196678 Log: As part of r196609, a call to rtalloc did not take the fib into account. So call the appropriate rtalloc_ign_fib() instead of calling rtalloc_ign(). Reviewed by:i pointed out by bz MFC after:immediately Modified: head/sys/net/rtsock.c Modified: head/sys/net/rtsock.c == --- head/sys/net/rtsock.c Sun Aug 30 23:16:52 2009(r196677) +++ head/sys/net/rtsock.c Mon Aug 31 00:14:37 2009(r196678) @@ -527,7 +527,7 @@ route_output(struct mbuf *m, struct sock bzero(gw_ro, sizeof(gw_ro)); gw_ro.ro_dst = *info.rti_info[RTAX_GATEWAY]; - rtalloc_ign(gw_ro, 0); + rtalloc_ign_fib(gw_ro, 0, so-so_fibnum); /* * A host route through the loopback interface is * installed for each interface adddress. In pre 8.0 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
RE: svn commit: r196673 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net
With this change, can I mark the following two TODO items as done: * RTM_CHANGE in net/rtsock.c can incorrectly set RTF_GATEWAY (QingLi) (in progress) * flowtable mishandles gateway (G) routes on POINT2POINT interfaces (BrianSomers) (in progress) AFAIK, Yes. Also, do we believe your last few commits fix the three issues raised by Sato-san in his IPv6 reports: * IPv6 regression on 8.x (QingLi) (in progress) One is reported as remaining, which I will investigate today and hope to take care of it soon. -- Qing ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
RE: svn commit: r196679 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net
On Mon, 31 Aug 2009, Qing Li wrote: As part of r196609, a call to rtalloc did not take the fib into account. So call the appropriate rtalloc_ign_fib() instead of calling rtalloc_ign(). Reviewed by: pointed out by bz Approved by: re I don't have this in my list of re-approved merges. Are you sure this change was approved by re? From Kostik Belousov: There was (unhandled) note from Bjoern about interaction with FIB. Patch is approved, but please take care of that note. I assume it's fine. -- Qing ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r196714 - head/sys/netinet
Author: qingli Date: Mon Aug 31 21:02:48 2009 New Revision: 196714 URL: http://svn.freebsd.org/changeset/base/196714 Log: This patch fixes the following issues: - Routing messages are not generated when adding and removing interface address aliases. - Loopback route installed for an interface address alias is not deleted from the routing table when that address alias is removed from the associated interface. - Function in_ifscrub() is called extraneously. Reviewed by: gnn, kmacy, sam MFC after:3 days Modified: head/sys/netinet/in.c Modified: head/sys/netinet/in.c == --- head/sys/netinet/in.c Mon Aug 31 20:59:23 2009(r196713) +++ head/sys/netinet/in.c Mon Aug 31 21:02:48 2009(r196714) @@ -536,7 +536,6 @@ in_control(struct socket *so, u_long cmd hostIsNew = 0; } if (ifra-ifra_mask.sin_len) { - in_ifscrub(ifp, ia); ia-ia_sockmask = ifra-ifra_mask; ia-ia_sockmask.sin_family = AF_INET; ia-ia_subnetmask = @@ -545,7 +544,6 @@ in_control(struct socket *so, u_long cmd } if ((ifp-if_flags IFF_POINTOPOINT) (ifra-ifra_dstaddr.sin_family == AF_INET)) { - in_ifscrub(ifp, ia); ia-ia_dstaddr = ifra-ifra_dstaddr; maskIsNew = 1; /* We lie; but the effect's the same */ } @@ -991,6 +989,40 @@ in_addprefix(struct in_ifaddr *target, i IN_IFADDR_RUNLOCK(); return (EEXIST); } else { + struct route pfx_ro; + struct sockaddr_in *pfx_addr; + struct rtentry msg_rt; + + /* QL: XXX +* This is a bit questionable because there is no +* additional route entry added for an address alias. +* Therefore this route report is inaccurate. Perhaps +* it's better to supply a empty rtentry as how it +* is done in in_scrubprefix(). +*/ + bzero(pfx_ro, sizeof(pfx_ro)); + pfx_addr = (struct sockaddr_in *)(pfx_ro.ro_dst); + pfx_addr-sin_len = sizeof(*pfx_addr); + pfx_addr-sin_family = AF_INET; + pfx_addr-sin_addr = prefix; + rtalloc_ign_fib(pfx_ro, 0, 0); + if (pfx_ro.ro_rt != NULL) { + msg_rt = *pfx_ro.ro_rt; + /* QL: XXX +* Point the gateway to the given interface +* address as if a new prefix route entry has +* been added through the new address alias. +* All other parts of the rtentry is accurate, +* e.g., rt_key, rt_mask, rt_ifp etc. +*/ + msg_rt.rt_gateway = + (struct sockaddr *)ia-ia_addr; + rt_newaddrmsg(RTM_ADD, + (struct ifaddr *)target, + 0, msg_rt); + RTFREE(pfx_ro.ro_rt); + } + IN_IFADDR_RUNLOCK(); return (0); } @@ -1024,9 +1056,6 @@ in_scrubprefix(struct in_ifaddr *target) struct rt_addrinfo info; struct sockaddr_dl null_sdl; - if ((target-ia_flags IFA_ROUTE) == 0) - return (0); - /* * Remove the loopback route to the interface address. * The useloopback setting is not consulted because if the @@ -1054,6 +1083,20 @@ in_scrubprefix(struct in_ifaddr *target) log(LOG_INFO, in_scrubprefix: deletion failed\n); } + if ((target-ia_flags IFA_ROUTE) == 0) { + struct rtentry rt; + + /* QL: XXX +* Report a blank rtentry when a route has not been +* installed for the given interface address. +*/ + bzero(rt, sizeof(rt)); + rt_newaddrmsg(RTM_DELETE, + (struct ifaddr *)target, +
svn commit: r196865 - head/sys/netinet6
Author: qingli Date: Sat Sep 5 16:50:55 2009 New Revision: 196865 URL: http://svn.freebsd.org/changeset/base/196865 Log: This patch fixes an address scope violation. Considering the scenario where an anycast address is assigned on one interface, and a global address with the same scope is assigned on another interface. In other words, the interface owns the anycast address has only the link-local address as one other address. Without this patch, ping6 the anycast address from another station will observe the source address of the returned ICMP6 echo reply has the link-local address, not the global address that exists on the other interface in the same node. Reviewed by: bz MFC after:immediately Modified: head/sys/netinet6/icmp6.c Modified: head/sys/netinet6/icmp6.c == --- head/sys/netinet6/icmp6.c Sat Sep 5 16:43:16 2009(r196864) +++ head/sys/netinet6/icmp6.c Sat Sep 5 16:50:55 2009(r196865) @@ -2170,6 +2170,10 @@ icmp6_reflect(struct mbuf *m, size_t off } } + if ((srcp != NULL) + (in6_addrscope(srcp) != in6_addrscope(ip6-ip6_src))) + srcp = NULL; + if (srcp == NULL) { int e; struct sockaddr_in6 sin6; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r196864 - in head/sys: net netinet6
Author: qingli Date: Sat Sep 5 16:43:16 2009 New Revision: 196864 URL: http://svn.freebsd.org/changeset/base/196864 Log: This patch fixes the following issues: - Interface link-local address is not reachable within the node that owns the interface, this is due to the mismatch in address scope as the result of the installed interface address loopback route. Therefore for each interface address loopback route, the rt_gateway field (of AF_LINK type) will be used to track which interface a given address belongs to. This will aid the address source to use the proper interface for address scope/zone validation. - The loopback address is not reachable. The root cause is the same as the above. - Empty nd6 entries are created for the IPv6 loopback addresses only for validation reason. Doing so will eliminate as much of the special case (loopback addresses) handling code as possible, however, these empty nd6 entries should not be returned to the userland applications such as the ndp command. Since both of the above issues contain common files, these files are committed together. Reviewed by: bz MFC after:immediately Modified: head/sys/net/if_llatbl.c head/sys/netinet6/in6.c head/sys/netinet6/in6_src.c head/sys/netinet6/ip6_output.c Modified: head/sys/net/if_llatbl.c == --- head/sys/net/if_llatbl.cSat Sep 5 15:08:58 2009(r196863) +++ head/sys/net/if_llatbl.cSat Sep 5 16:43:16 2009(r196864) @@ -263,6 +263,15 @@ lla_rt_output(struct rt_msghdr *rtm, str __func__, dl-sdl_index); return EINVAL; } + if (ifp-if_flags IFF_LOOPBACK) { + struct ifaddr *ia; + ia = ifa_ifwithaddr(dst); + if (ia != NULL) { + ifp = ia-ifa_ifp; + ifa_free(ia); + } else + return EINVAL; + } switch (rtm-rtm_type) { case RTM_ADD: Modified: head/sys/netinet6/in6.c == --- head/sys/netinet6/in6.c Sat Sep 5 15:08:58 2009(r196863) +++ head/sys/netinet6/in6.c Sat Sep 5 16:43:16 2009(r196864) @@ -1201,8 +1201,8 @@ in6_purgeaddr(struct ifaddr *ifa) bzero(null_sdl, sizeof(null_sdl)); null_sdl.sdl_len = sizeof(null_sdl); null_sdl.sdl_family = AF_LINK; - null_sdl.sdl_type = V_loif-if_type; - null_sdl.sdl_index = V_loif-if_index; + null_sdl.sdl_type = ia-ia_ifp-if_type; + null_sdl.sdl_index = ia-ia_ifp-if_index; bzero(info, sizeof(info)); info.rti_flags = ia-ia_flags | RTF_HOST | RTF_STATIC; info.rti_info[RTAX_DST] = (struct sockaddr *)ia-ia_addr; @@ -1782,9 +1782,9 @@ in6_ifinit(struct ifnet *ifp, struct in6 if (error == 0 rt != NULL) { RT_LOCK(rt); ((struct sockaddr_dl *)rt-rt_gateway)-sdl_type = - rt-rt_ifp-if_type; + ifp-if_type; ((struct sockaddr_dl *)rt-rt_gateway)-sdl_index = - rt-rt_ifp-if_index; + ifp-if_index; RT_REMREF(rt); RT_UNLOCK(rt); } else if (error != 0) @@ -2495,6 +2495,9 @@ in6_lltable_dump(struct lltable *llt, st } ndpc; int i, error; + if (ifp-if_flags IFF_LOOPBACK) + return 0; + LLTABLE_LOCK_ASSERT(); error = 0; Modified: head/sys/netinet6/in6_src.c == --- head/sys/netinet6/in6_src.c Sat Sep 5 15:08:58 2009(r196863) +++ head/sys/netinet6/in6_src.c Sat Sep 5 16:43:16 2009(r196864) @@ -85,6 +85,7 @@ __FBSDID($FreeBSD$); #include sys/sx.h #include net/if.h +#include net/if_dl.h #include net/route.h #include net/if_llatbl.h #ifdef RADIX_MPATH @@ -697,8 +698,25 @@ selectroute(struct sockaddr_in6 *dstsock if (error == EHOSTUNREACH) V_ip6stat.ip6s_noroute++; - if (retifp != NULL) + if (retifp != NULL) { *retifp = ifp; + + /* +* Adjust the outgoing interface. If we're going to loop +* the packet back to ourselves, the ifp would be the loopback +* interface. However, we'd rather know the interface associated +* to the destination address (which should probably be one of +* our own addresses.) +*/ + if (rt) { + if ((rt-rt_ifp-if_flags IFF_LOOPBACK) +
svn commit: r196868 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet6
Author: qingli Date: Sat Sep 5 17:35:31 2009 New Revision: 196868 URL: http://svn.freebsd.org/changeset/base/196868 Log: MFC r196865 This patch fixes an address scope violation. Considering the scenario where an anycast address is assigned on one interface, and a global address with the same scope is assigned on another interface. In other words, the interface owns the anycast address has only the link-local address as one other address. Without this patch, ping6 the anycast address from another station will observe the source address of the returned ICMP6 echo reply has the link-local address, not the global address that exists on the other interface in the same node. Reviewed by:bz Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet6/icmp6.c Modified: stable/8/sys/netinet6/icmp6.c == --- stable/8/sys/netinet6/icmp6.c Sat Sep 5 17:29:08 2009 (r196867) +++ stable/8/sys/netinet6/icmp6.c Sat Sep 5 17:35:31 2009 (r196868) @@ -2170,6 +2170,10 @@ icmp6_reflect(struct mbuf *m, size_t off } } + if ((srcp != NULL) + (in6_addrscope(srcp) != in6_addrscope(ip6-ip6_src))) + srcp = NULL; + if (srcp == NULL) { int e; struct sockaddr_in6 sin6; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r196869 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net netinet6
Author: qingli Date: Sat Sep 5 17:40:27 2009 New Revision: 196869 URL: http://svn.freebsd.org/changeset/base/196869 Log: MFC r196864 This patch fixes the following issues: - Interface link-local address is not reachable within the node that owns the interface, this is due to the mismatch in address scope as the result of the installed interface address loopback route. Therefore for each interface address loopback route, the rt_gateway field (of AF_LINK type) will be used to track which interface a given address belongs to. This will aid the address source to use the proper interface for address scope/zone validation. - The loopback address is not reachable. The root cause is the same as the above. - Empty nd6 entries are created for the IPv6 loopback addresses only for validation reason. Doing so will eliminate as much of the special case (loopback addresses) handling code as possible, however, these empty nd6 entries should not be returned to the userland applications such as the ndp command. Since both of the above issues contain common files, these files are committed together. Reviewed by: bz Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/if_llatbl.c stable/8/sys/netinet6/in6.c stable/8/sys/netinet6/in6_src.c stable/8/sys/netinet6/ip6_output.c Modified: stable/8/sys/net/if_llatbl.c == --- stable/8/sys/net/if_llatbl.cSat Sep 5 17:35:31 2009 (r196868) +++ stable/8/sys/net/if_llatbl.cSat Sep 5 17:40:27 2009 (r196869) @@ -263,6 +263,15 @@ lla_rt_output(struct rt_msghdr *rtm, str __func__, dl-sdl_index); return EINVAL; } + if (ifp-if_flags IFF_LOOPBACK) { + struct ifaddr *ia; + ia = ifa_ifwithaddr(dst); + if (ia != NULL) { + ifp = ia-ifa_ifp; + ifa_free(ia); + } else + return EINVAL; + } switch (rtm-rtm_type) { case RTM_ADD: Modified: stable/8/sys/netinet6/in6.c == --- stable/8/sys/netinet6/in6.c Sat Sep 5 17:35:31 2009(r196868) +++ stable/8/sys/netinet6/in6.c Sat Sep 5 17:40:27 2009(r196869) @@ -1201,8 +1201,8 @@ in6_purgeaddr(struct ifaddr *ifa) bzero(null_sdl, sizeof(null_sdl)); null_sdl.sdl_len = sizeof(null_sdl); null_sdl.sdl_family = AF_LINK; - null_sdl.sdl_type = V_loif-if_type; - null_sdl.sdl_index = V_loif-if_index; + null_sdl.sdl_type = ia-ia_ifp-if_type; + null_sdl.sdl_index = ia-ia_ifp-if_index; bzero(info, sizeof(info)); info.rti_flags = ia-ia_flags | RTF_HOST | RTF_STATIC; info.rti_info[RTAX_DST] = (struct sockaddr *)ia-ia_addr; @@ -1782,9 +1782,9 @@ in6_ifinit(struct ifnet *ifp, struct in6 if (error == 0 rt != NULL) { RT_LOCK(rt); ((struct sockaddr_dl *)rt-rt_gateway)-sdl_type = - rt-rt_ifp-if_type; + ifp-if_type; ((struct sockaddr_dl *)rt-rt_gateway)-sdl_index = - rt-rt_ifp-if_index; + ifp-if_index; RT_REMREF(rt); RT_UNLOCK(rt); } else if (error != 0) @@ -2495,6 +2495,9 @@ in6_lltable_dump(struct lltable *llt, st } ndpc; int i, error; + if (ifp-if_flags IFF_LOOPBACK) + return 0; + LLTABLE_LOCK_ASSERT(); error = 0; Modified: stable/8/sys/netinet6/in6_src.c == --- stable/8/sys/netinet6/in6_src.c Sat Sep 5 17:35:31 2009 (r196868) +++ stable/8/sys/netinet6/in6_src.c Sat Sep 5 17:40:27 2009 (r196869) @@ -85,6 +85,7 @@ __FBSDID($FreeBSD$); #include sys/sx.h #include net/if.h +#include net/if_dl.h #include net/route.h #include net/if_llatbl.h #ifdef RADIX_MPATH @@ -697,8 +698,25 @@ selectroute(struct sockaddr_in6 *dstsock if (error == EHOSTUNREACH) V_ip6stat.ip6s_noroute++; - if (retifp != NULL) + if (retifp != NULL) { *retifp = ifp; + + /* +* Adjust the outgoing interface. If we're going to loop +* the packet back to ourselves, the ifp would be
svn commit: r196872 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net netinet6
Author: qingli Date: Sat Sep 5 20:35:18 2009 New Revision: 196872 URL: http://svn.freebsd.org/changeset/base/196872 Log: MFC r196871 The addresses that are assigned to the loopback interface should be part of the kernel routing table. Reviewed by: bz Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/if_llatbl.c stable/8/sys/netinet6/in6.c Modified: stable/8/sys/net/if_llatbl.c == --- stable/8/sys/net/if_llatbl.cSat Sep 5 20:24:37 2009 (r196871) +++ stable/8/sys/net/if_llatbl.cSat Sep 5 20:35:18 2009 (r196872) @@ -263,15 +263,6 @@ lla_rt_output(struct rt_msghdr *rtm, str __func__, dl-sdl_index); return EINVAL; } - if (ifp-if_flags IFF_LOOPBACK) { - struct ifaddr *ia; - ia = ifa_ifwithaddr(dst); - if (ia != NULL) { - ifp = ia-ifa_ifp; - ifa_free(ia); - } else - return EINVAL; - } switch (rtm-rtm_type) { case RTM_ADD: Modified: stable/8/sys/netinet6/in6.c == --- stable/8/sys/netinet6/in6.c Sat Sep 5 20:24:37 2009(r196871) +++ stable/8/sys/netinet6/in6.c Sat Sep 5 20:35:18 2009(r196872) @@ -1192,9 +1192,10 @@ in6_purgeaddr(struct ifaddr *ifa) /* * Remove the loopback route to the interface address. -* The check for the current setting of nd6_useloopback is not needed. +* The check for the current setting of nd6_useloopback +* is not needed. */ - if (!(ia-ia_ifp-if_flags IFF_LOOPBACK)) { + { struct rt_addrinfo info; struct sockaddr_dl null_sdl; @@ -1767,7 +1768,9 @@ in6_ifinit(struct ifnet *ifp, struct in6 /* * add a loopback route to self */ - if (V_nd6_useloopback !(ifp-if_flags IFF_LOOPBACK)) { + if (!(ia-ia_flags IFA_ROUTE) +(V_nd6_useloopback + || (ifp-if_flags IFF_LOOPBACK))) { struct rt_addrinfo info; struct rtentry *rt = NULL; static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK}; @@ -1788,7 +1791,7 @@ in6_ifinit(struct ifnet *ifp, struct in6 RT_REMREF(rt); RT_UNLOCK(rt); } else if (error != 0) - log(LOG_INFO, in6_ifinit: insertion failed\n); + log(LOG_INFO, in6_ifinit: error = %d, insertion failed\n, error); } /* Add ownaddr as loopback rtentry, if necessary (ex. on p2p link). */ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197203 - head/sys/netinet
Author: qingli Date: Mon Sep 14 22:19:47 2009 New Revision: 197203 URL: http://svn.freebsd.org/changeset/base/197203 Log: Previously local end of point-to-point interface is not reachable within the system that owns the interface. Packets destined to the local end point leak to the wire towards the default gateway if one exists. This behavior is changed as part of the L2/L3 rewrite efforts. The local end point is now reachable within the system. The inpcb code needs to consider this fact during the address selection process. Reviewed by: bz MFC after:immediately Modified: head/sys/netinet/in_pcb.c Modified: head/sys/netinet/in_pcb.c == --- head/sys/netinet/in_pcb.c Mon Sep 14 21:33:00 2009(r197202) +++ head/sys/netinet/in_pcb.c Mon Sep 14 22:19:47 2009(r197203) @@ -701,6 +701,8 @@ in_pcbladdr(struct inpcb *inp, struct in ia = ifatoia(ifa_ifwithdstaddr(sintosa(sain))); if (ia == NULL) ia = ifatoia(ifa_ifwithnet(sintosa(sain))); + if (ia == NULL) + ia = ifatoia(ifa_ifwithaddr(sintosa(sain))); if (cred == NULL || !prison_flag(cred, PR_IP4)) { if (ia == NULL) { ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197210 - in head/sys: netinet nfsclient
Author: qingli Date: Tue Sep 15 01:01:03 2009 New Revision: 197210 URL: http://svn.freebsd.org/changeset/base/197210 Log: The bootp code installs an interface address and the nfs client module tries to install the same address again. This extra code is removed, which was discovered by the removal of a call to in_ifscrub() in r196714. This call to in_ifscrub is put back here because the SIOCAIFADDR command can be used to change the prefix length of an existing alias. Reviewed by:kmacy Modified: head/sys/netinet/in.c head/sys/nfsclient/nfs_vfsops.c Modified: head/sys/netinet/in.c == --- head/sys/netinet/in.c Tue Sep 15 00:26:23 2009(r197209) +++ head/sys/netinet/in.c Tue Sep 15 01:01:03 2009(r197210) @@ -536,6 +536,16 @@ in_control(struct socket *so, u_long cmd hostIsNew = 0; } if (ifra-ifra_mask.sin_len) { + /* +* QL: XXX +* Need to scrub the prefix here in case +* the issued command is SIOCAIFADDR with +* the same address, but with a different +* prefix length. And if the prefix length +* is the same as before, then the call is +* un-necessarily executed here. +*/ + in_ifscrub(ifp, ia); ia-ia_sockmask = ifra-ifra_mask; ia-ia_sockmask.sin_family = AF_INET; ia-ia_subnetmask = @@ -544,6 +554,7 @@ in_control(struct socket *so, u_long cmd } if ((ifp-if_flags IFF_POINTOPOINT) (ifra-ifra_dstaddr.sin_family == AF_INET)) { + in_ifscrub(ifp, ia); ia-ia_dstaddr = ifra-ifra_dstaddr; maskIsNew = 1; /* We lie; but the effect's the same */ } Modified: head/sys/nfsclient/nfs_vfsops.c == --- head/sys/nfsclient/nfs_vfsops.c Tue Sep 15 00:26:23 2009 (r197209) +++ head/sys/nfsclient/nfs_vfsops.c Tue Sep 15 01:01:03 2009 (r197210) @@ -463,9 +463,13 @@ nfs_mountroot(struct mount *mp) break; } #endif + +#if 0 /* QL: XXX */ error = ifioctl(so, SIOCAIFADDR, (caddr_t)nd-myif, td); if (error) panic(nfs_mountroot: SIOCAIFADDR: %d, error); +#endif + if ((cp = getenv(boot.netif.mtu)) != NULL) { ir.ifr_mtu = strtol(cp, NULL, 10); bcopy(nd-myif.ifra_name, ir.ifr_name, IFNAMSIZ); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197212 - head/sys/nfsclient
Author: qingli Date: Tue Sep 15 02:22:57 2009 New Revision: 197212 URL: http://svn.freebsd.org/changeset/base/197212 Log: Simply remove the code instead of using #if 0. Pointed out by sam Modified: head/sys/nfsclient/nfs_vfsops.c Modified: head/sys/nfsclient/nfs_vfsops.c == --- head/sys/nfsclient/nfs_vfsops.c Tue Sep 15 02:04:16 2009 (r197211) +++ head/sys/nfsclient/nfs_vfsops.c Tue Sep 15 02:22:57 2009 (r197212) @@ -464,12 +464,6 @@ nfs_mountroot(struct mount *mp) } #endif -#if 0 /* QL: XXX */ - error = ifioctl(so, SIOCAIFADDR, (caddr_t)nd-myif, td); - if (error) - panic(nfs_mountroot: SIOCAIFADDR: %d, error); -#endif - if ((cp = getenv(boot.netif.mtu)) != NULL) { ir.ifr_mtu = strtol(cp, NULL, 10); bcopy(nd-myif.ifra_name, ir.ifr_name, IFNAMSIZ); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197225 - head/sys/netinet
Author: qingli Date: Tue Sep 15 18:39:27 2009 New Revision: 197225 URL: http://svn.freebsd.org/changeset/base/197225 Log: This patch enables the node to respond to ARP requests for configured proxy ARP entries. Reviewed by: bz MFC after:immediately Modified: head/sys/netinet/if_ether.c Modified: head/sys/netinet/if_ether.c == --- head/sys/netinet/if_ether.c Tue Sep 15 16:59:52 2009(r197224) +++ head/sys/netinet/if_ether.c Tue Sep 15 18:39:27 2009(r197225) @@ -714,62 +714,70 @@ reply: } else { struct llentry *lle = NULL; - if (!V_arp_proxyall) - goto drop; - sin.sin_addr = itaddr; - /* XXX MRT use table 0 for arp reply */ - rt = in_rtalloc1((struct sockaddr *)sin, 0, 0UL, 0); - if (!rt) - goto drop; - - /* -* Don't send proxies for nodes on the same interface -* as this one came out of, or we'll get into a fight -* over who claims what Ether address. -*/ - if (!rt-rt_ifp || rt-rt_ifp == ifp) { - RTFREE_LOCKED(rt); - goto drop; - } - IF_AFDATA_LOCK(rt-rt_ifp); - lle = lla_lookup(LLTABLE(rt-rt_ifp), 0, (struct sockaddr *)sin); - IF_AFDATA_UNLOCK(rt-rt_ifp); - RTFREE_LOCKED(rt); + IF_AFDATA_LOCK(ifp); + lle = lla_lookup(LLTABLE(ifp), 0, (struct sockaddr *)sin); + IF_AFDATA_UNLOCK(ifp); - if (lle != NULL) { + if ((lle != NULL) (lle-la_flags LLE_PUB)) { (void)memcpy(ar_tha(ah), ar_sha(ah), ah-ar_hln); (void)memcpy(ar_sha(ah), lle-ll_addr, ah-ar_hln); LLE_RUNLOCK(lle); - } else - goto drop; + } else { - /* -* Also check that the node which sent the ARP packet -* is on the the interface we expect it to be on. This -* avoids ARP chaos if an interface is connected to the -* wrong network. -*/ - sin.sin_addr = isaddr; + if (lle != NULL) + LLE_RUNLOCK(lle); - /* XXX MRT use table 0 for arp checks */ - rt = in_rtalloc1((struct sockaddr *)sin, 0, 0UL, 0); - if (!rt) - goto drop; - if (rt-rt_ifp != ifp) { - log(LOG_INFO, arp_proxy: ignoring request -from %s via %s, expecting %s\n, - inet_ntoa(isaddr), ifp-if_xname, - rt-rt_ifp-if_xname); + if (!V_arp_proxyall) + goto drop; + + sin.sin_addr = itaddr; + /* XXX MRT use table 0 for arp reply */ + rt = in_rtalloc1((struct sockaddr *)sin, 0, 0UL, 0); + if (!rt) + goto drop; + + /* +* Don't send proxies for nodes on the same interface +* as this one came out of, or we'll get into a fight +* over who claims what Ether address. +*/ + if (!rt-rt_ifp || rt-rt_ifp == ifp) { + RTFREE_LOCKED(rt); + goto drop; + } + RTFREE_LOCKED(rt); + + (void)memcpy(ar_tha(ah), ar_sha(ah), ah-ar_hln); + (void)memcpy(ar_sha(ah), enaddr, ah-ar_hln); + + /* +* Also check that the node which sent the ARP packet +* is on the the interface we expect it to be on. This +* avoids ARP chaos if an interface is connected to the +* wrong network. +*/ + sin.sin_addr = isaddr; + + /* XXX MRT use table 0 for arp checks */ + rt = in_rtalloc1((struct sockaddr *)sin, 0, 0UL, 0); + if (!rt) + goto drop; + if (rt-rt_ifp != ifp) { + log(LOG_INFO, arp_proxy: ignoring request +from %s via %s, expecting %s\n, + inet_ntoa(isaddr), ifp-if_xname, + rt-rt_ifp-if_xname); + RTFREE_LOCKED(rt); +
svn commit: r197227 - in head/sys: net netinet netinet6
Author: qingli Date: Tue Sep 15 19:18:34 2009 New Revision: 197227 URL: http://svn.freebsd.org/changeset/base/197227 Log: Self pointing routes are installed for configured interface addresses and address aliases. After an interface is brought down and brought back up again, those self pointing routes disappeared. This patch ensures after an interface is brought back up, the loopback routes are reinstalled properly. Reviewed by: bz MFC after:immediately Modified: head/sys/net/if.c head/sys/net/if_var.h head/sys/netinet/in.c head/sys/netinet/raw_ip.c head/sys/netinet6/in6.c Modified: head/sys/net/if.c == --- head/sys/net/if.c Tue Sep 15 19:14:25 2009(r197226) +++ head/sys/net/if.c Tue Sep 15 19:18:34 2009(r197227) @@ -1414,6 +1414,59 @@ ifa_free(struct ifaddr *ifa) } } +int +ifa_add_loopback_route(struct ifaddr *ifa, struct sockaddr *ia) +{ + int error = 0; + struct rtentry *rt = NULL; + struct rt_addrinfo info; + static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK}; + + bzero(info, sizeof(info)); + info.rti_ifp = V_loif; + info.rti_flags = ifa-ifa_flags | RTF_HOST | RTF_STATIC; + info.rti_info[RTAX_DST] = ia; + info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)null_sdl; + error = rtrequest1_fib(RTM_ADD, info, rt, 0); + + if (error == 0 rt != NULL) { + RT_LOCK(rt); + ((struct sockaddr_dl *)rt-rt_gateway)-sdl_type = + rt-rt_ifp-if_type; + ((struct sockaddr_dl *)rt-rt_gateway)-sdl_index = + rt-rt_ifp-if_index; + RT_REMREF(rt); + RT_UNLOCK(rt); + } else if (error != 0) + log(LOG_INFO, ifa_add_loopback_route: insertion failed\n); + + return (error); +} + +int +ifa_del_loopback_route(struct ifaddr *ifa, struct sockaddr *ia) +{ + int error = 0; + struct rt_addrinfo info; + struct sockaddr_dl null_sdl; + + bzero(null_sdl, sizeof(null_sdl)); + null_sdl.sdl_len = sizeof(null_sdl); + null_sdl.sdl_family = AF_LINK; + null_sdl.sdl_type = ifa-ifa_ifp-if_type; + null_sdl.sdl_index = ifa-ifa_ifp-if_index; + bzero(info, sizeof(info)); + info.rti_flags = ifa-ifa_flags | RTF_HOST | RTF_STATIC; + info.rti_info[RTAX_DST] = ia; + info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)null_sdl; + error = rtrequest1_fib(RTM_DELETE, info, NULL, 0); + + if (error != 0) + log(LOG_INFO, ifa_del_loopback_route: deletion failed\n); + + return (error); +} + /* * XXX: Because sockaddr_dl has deeper structure than the sockaddr * structs used to represent other address families, it is necessary Modified: head/sys/net/if_var.h == --- head/sys/net/if_var.h Tue Sep 15 19:14:25 2009(r197226) +++ head/sys/net/if_var.h Tue Sep 15 19:18:34 2009(r197227) @@ -854,6 +854,9 @@ struct ifnet *ifunit_ref(const char *); void ifq_init(struct ifaltq *, struct ifnet *ifp); void ifq_delete(struct ifaltq *); +intifa_add_loopback_route(struct ifaddr *, struct sockaddr *); +intifa_del_loopback_route(struct ifaddr *, struct sockaddr *); + struct ifaddr *ifa_ifwithaddr(struct sockaddr *); intifa_ifwithaddr_check(struct sockaddr *); struct ifaddr *ifa_ifwithbroadaddr(struct sockaddr *); Modified: head/sys/netinet/in.c == --- head/sys/netinet/in.c Tue Sep 15 19:14:25 2009(r197226) +++ head/sys/netinet/in.c Tue Sep 15 19:18:34 2009(r197227) @@ -827,9 +827,6 @@ in_ifinit(struct ifnet *ifp, struct in_i { register u_long i = ntohl(sin-sin_addr.s_addr); struct sockaddr_in oldaddr; - struct rtentry *rt = NULL; - struct rt_addrinfo info; - static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK}; int s = splimp(), flags = RTF_UP, error = 0; oldaddr = ia-ia_addr; @@ -927,25 +924,9 @@ in_ifinit(struct ifnet *ifp, struct in_i /* * add a loopback route to self */ - if (V_useloopback !(ifp-if_flags IFF_LOOPBACK)) { - bzero(info, sizeof(info)); - info.rti_ifp = V_loif; - info.rti_flags = ia-ia_flags | RTF_HOST | RTF_STATIC; - info.rti_info[RTAX_DST] = (struct sockaddr *)ia-ia_addr; - info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)null_sdl; - error = rtrequest1_fib(RTM_ADD, info, rt, 0); - - if (error == 0 rt != NULL) { - RT_LOCK(rt); - ((struct sockaddr_dl *)rt-rt_gateway)-sdl_type = - rt-rt_ifp-if_type; -
svn commit: r197231 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet
Author: qingli Date: Tue Sep 15 19:58:33 2009 New Revision: 197231 URL: http://svn.freebsd.org/changeset/base/197231 Log: MFC r196714 This patch fixes the following issues: - Routing messages are not generated when adding and removing interface address aliases. - Loopback route installed for an interface address alias is not deleted from the routing table when that address alias is removed from the associated interface. - Function in_ifscrub() is called extraneously. Reviewed by: gnn, kmacy, sam Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet/in.c Modified: stable/8/sys/netinet/in.c == --- stable/8/sys/netinet/in.c Tue Sep 15 19:56:35 2009(r197230) +++ stable/8/sys/netinet/in.c Tue Sep 15 19:58:33 2009(r197231) @@ -536,7 +536,6 @@ in_control(struct socket *so, u_long cmd hostIsNew = 0; } if (ifra-ifra_mask.sin_len) { - in_ifscrub(ifp, ia); ia-ia_sockmask = ifra-ifra_mask; ia-ia_sockmask.sin_family = AF_INET; ia-ia_subnetmask = @@ -545,7 +544,6 @@ in_control(struct socket *so, u_long cmd } if ((ifp-if_flags IFF_POINTOPOINT) (ifra-ifra_dstaddr.sin_family == AF_INET)) { - in_ifscrub(ifp, ia); ia-ia_dstaddr = ifra-ifra_dstaddr; maskIsNew = 1; /* We lie; but the effect's the same */ } @@ -991,6 +989,40 @@ in_addprefix(struct in_ifaddr *target, i IN_IFADDR_RUNLOCK(); return (EEXIST); } else { + struct route pfx_ro; + struct sockaddr_in *pfx_addr; + struct rtentry msg_rt; + + /* QL: XXX +* This is a bit questionable because there is no +* additional route entry added for an address alias. +* Therefore this route report is inaccurate. Perhaps +* it's better to supply a empty rtentry as how it +* is done in in_scrubprefix(). +*/ + bzero(pfx_ro, sizeof(pfx_ro)); + pfx_addr = (struct sockaddr_in *)(pfx_ro.ro_dst); + pfx_addr-sin_len = sizeof(*pfx_addr); + pfx_addr-sin_family = AF_INET; + pfx_addr-sin_addr = prefix; + rtalloc_ign_fib(pfx_ro, 0, 0); + if (pfx_ro.ro_rt != NULL) { + msg_rt = *pfx_ro.ro_rt; + /* QL: XXX +* Point the gateway to the given interface +* address as if a new prefix route entry has +* been added through the new address alias. +* All other parts of the rtentry is accurate, +* e.g., rt_key, rt_mask, rt_ifp etc. +*/ + msg_rt.rt_gateway = + (struct sockaddr *)ia-ia_addr; + rt_newaddrmsg(RTM_ADD, + (struct ifaddr *)target, + 0, msg_rt); + RTFREE(pfx_ro.ro_rt); + } + IN_IFADDR_RUNLOCK(); return (0); } @@ -1024,9 +1056,6 @@ in_scrubprefix(struct in_ifaddr *target) struct rt_addrinfo info; struct sockaddr_dl null_sdl; - if ((target-ia_flags IFA_ROUTE) == 0) - return (0); - /* * Remove the loopback route to the interface address. * The useloopback setting is not consulted because if the @@ -1054,6 +1083,20 @@ in_scrubprefix(struct in_ifaddr *target) log(LOG_INFO, in_scrubprefix: deletion failed\n); } + if ((target-ia_flags IFA_ROUTE) == 0) { + struct rtentry rt; + +
svn commit: r197235 - head/sys/nfsclient
Author: qingli Date: Tue Sep 15 22:09:42 2009 New Revision: 197235 URL: http://svn.freebsd.org/changeset/base/197235 Log: Reverting the previous change for now. Some users reports the patch fixes their issues but one reports a failure in NFS ROOT. Revert the change for now pending further investigation. Reviewed by: bz MFC after:immediately Modified: head/sys/nfsclient/nfs_vfsops.c Modified: head/sys/nfsclient/nfs_vfsops.c == --- head/sys/nfsclient/nfs_vfsops.c Tue Sep 15 21:15:29 2009 (r197234) +++ head/sys/nfsclient/nfs_vfsops.c Tue Sep 15 22:09:42 2009 (r197235) @@ -464,6 +464,10 @@ nfs_mountroot(struct mount *mp) } #endif + error = ifioctl(so, SIOCAIFADDR, (caddr_t)nd-myif, td); + if (error) + panic(nfs_mountroot: SIOCAIFADDR: %d, error); + if ((cp = getenv(boot.netif.mtu)) != NULL) { ir.ifr_mtu = strtol(cp, NULL, 10); bcopy(nd-myif.ifra_name, ir.ifr_name, IFNAMSIZ); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197237 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet nfsclient
Author: qingli Date: Tue Sep 15 22:25:19 2009 New Revision: 197237 URL: http://svn.freebsd.org/changeset/base/197237 Log: MFC r197210, 197212, 197235 The bootp code installs an interface address and the nfs client module tries to install the same address again. This extra code is removed, which was discovered by the removal of a call to in_ifscrub() in r196714. This call to in_ifscrub is put back here because the SIOCAIFADDR command can be used to change the prefix length of an existing alias. r197235 reverts file nfs_vfsops.c Reviewed by: kmacy Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet/in.c stable/8/sys/nfsclient/nfs_vfsops.c Modified: stable/8/sys/netinet/in.c == --- stable/8/sys/netinet/in.c Tue Sep 15 22:23:45 2009(r197236) +++ stable/8/sys/netinet/in.c Tue Sep 15 22:25:19 2009(r197237) @@ -536,6 +536,16 @@ in_control(struct socket *so, u_long cmd hostIsNew = 0; } if (ifra-ifra_mask.sin_len) { + /* +* QL: XXX +* Need to scrub the prefix here in case +* the issued command is SIOCAIFADDR with +* the same address, but with a different +* prefix length. And if the prefix length +* is the same as before, then the call is +* un-necessarily executed here. +*/ + in_ifscrub(ifp, ia); ia-ia_sockmask = ifra-ifra_mask; ia-ia_sockmask.sin_family = AF_INET; ia-ia_subnetmask = @@ -544,6 +554,7 @@ in_control(struct socket *so, u_long cmd } if ((ifp-if_flags IFF_POINTOPOINT) (ifra-ifra_dstaddr.sin_family == AF_INET)) { + in_ifscrub(ifp, ia); ia-ia_dstaddr = ifra-ifra_dstaddr; maskIsNew = 1; /* We lie; but the effect's the same */ } Modified: stable/8/sys/nfsclient/nfs_vfsops.c == --- stable/8/sys/nfsclient/nfs_vfsops.c Tue Sep 15 22:23:45 2009 (r197236) +++ stable/8/sys/nfsclient/nfs_vfsops.c Tue Sep 15 22:25:19 2009 (r197237) @@ -463,9 +463,11 @@ nfs_mountroot(struct mount *mp) break; } #endif + error = ifioctl(so, SIOCAIFADDR, (caddr_t)nd-myif, td); if (error) panic(nfs_mountroot: SIOCAIFADDR: %d, error); + if ((cp = getenv(boot.netif.mtu)) != NULL) { ir.ifr_mtu = strtol(cp, NULL, 10); bcopy(nd-myif.ifra_name, ir.ifr_name, IFNAMSIZ); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197238 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet
Author: qingli Date: Tue Sep 15 22:37:17 2009 New Revision: 197238 URL: http://svn.freebsd.org/changeset/base/197238 Log: MFC r197225 This patch enables the node to respond to ARP requests for configured proxy ARP entries. Reviewed by: bz Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet/if_ether.c Modified: stable/8/sys/netinet/if_ether.c == --- stable/8/sys/netinet/if_ether.c Tue Sep 15 22:25:19 2009 (r197237) +++ stable/8/sys/netinet/if_ether.c Tue Sep 15 22:37:17 2009 (r197238) @@ -694,62 +694,70 @@ reply: } else { struct llentry *lle = NULL; - if (!V_arp_proxyall) - goto drop; - sin.sin_addr = itaddr; - /* XXX MRT use table 0 for arp reply */ - rt = in_rtalloc1((struct sockaddr *)sin, 0, 0UL, 0); - if (!rt) - goto drop; - - /* -* Don't send proxies for nodes on the same interface -* as this one came out of, or we'll get into a fight -* over who claims what Ether address. -*/ - if (!rt-rt_ifp || rt-rt_ifp == ifp) { - RTFREE_LOCKED(rt); - goto drop; - } - IF_AFDATA_LOCK(rt-rt_ifp); - lle = lla_lookup(LLTABLE(rt-rt_ifp), 0, (struct sockaddr *)sin); - IF_AFDATA_UNLOCK(rt-rt_ifp); - RTFREE_LOCKED(rt); + IF_AFDATA_LOCK(ifp); + lle = lla_lookup(LLTABLE(ifp), 0, (struct sockaddr *)sin); + IF_AFDATA_UNLOCK(ifp); - if (lle != NULL) { + if ((lle != NULL) (lle-la_flags LLE_PUB)) { (void)memcpy(ar_tha(ah), ar_sha(ah), ah-ar_hln); (void)memcpy(ar_sha(ah), lle-ll_addr, ah-ar_hln); LLE_RUNLOCK(lle); - } else - goto drop; + } else { - /* -* Also check that the node which sent the ARP packet -* is on the the interface we expect it to be on. This -* avoids ARP chaos if an interface is connected to the -* wrong network. -*/ - sin.sin_addr = isaddr; + if (lle != NULL) + LLE_RUNLOCK(lle); - /* XXX MRT use table 0 for arp checks */ - rt = in_rtalloc1((struct sockaddr *)sin, 0, 0UL, 0); - if (!rt) - goto drop; - if (rt-rt_ifp != ifp) { - log(LOG_INFO, arp_proxy: ignoring request -from %s via %s, expecting %s\n, - inet_ntoa(isaddr), ifp-if_xname, - rt-rt_ifp-if_xname); + if (!V_arp_proxyall) + goto drop; + + sin.sin_addr = itaddr; + /* XXX MRT use table 0 for arp reply */ + rt = in_rtalloc1((struct sockaddr *)sin, 0, 0UL, 0); + if (!rt) + goto drop; + + /* +* Don't send proxies for nodes on the same interface +* as this one came out of, or we'll get into a fight +* over who claims what Ether address. +*/ + if (!rt-rt_ifp || rt-rt_ifp == ifp) { + RTFREE_LOCKED(rt); + goto drop; + } + RTFREE_LOCKED(rt); + + (void)memcpy(ar_tha(ah), ar_sha(ah), ah-ar_hln); + (void)memcpy(ar_sha(ah), enaddr, ah-ar_hln); + + /* +* Also check that the node which sent the ARP packet +* is on the the interface we expect it to be on. This +* avoids ARP chaos if an interface is connected to the +* wrong network. +*/ + sin.sin_addr = isaddr; + + /* XXX MRT use table 0 for arp checks */ + rt = in_rtalloc1((struct sockaddr *)sin, 0, 0UL, 0); + if (!rt) + goto drop; + if (rt-rt_ifp != ifp) { +
svn commit: r197239 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net netinet netinet6
Author: qingli Date: Tue Sep 15 22:46:06 2009 New Revision: 197239 URL: http://svn.freebsd.org/changeset/base/197239 Log: MFC r197227 Self pointing routes are installed for configured interface addresses and address aliases. After an interface is brought down and brought back up again, those self pointing routes disappeared. This patch ensures after an interface is brought back up, the loopback routes are reinstalled properly. Reviewed by: bz Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/if.c stable/8/sys/net/if_var.h stable/8/sys/netinet/in.c stable/8/sys/netinet/raw_ip.c stable/8/sys/netinet6/in6.c Modified: stable/8/sys/net/if.c == --- stable/8/sys/net/if.c Tue Sep 15 22:37:17 2009(r197238) +++ stable/8/sys/net/if.c Tue Sep 15 22:46:06 2009(r197239) @@ -1414,6 +1414,59 @@ ifa_free(struct ifaddr *ifa) } } +int +ifa_add_loopback_route(struct ifaddr *ifa, struct sockaddr *ia) +{ + int error = 0; + struct rtentry *rt = NULL; + struct rt_addrinfo info; + static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK}; + + bzero(info, sizeof(info)); + info.rti_ifp = V_loif; + info.rti_flags = ifa-ifa_flags | RTF_HOST | RTF_STATIC; + info.rti_info[RTAX_DST] = ia; + info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)null_sdl; + error = rtrequest1_fib(RTM_ADD, info, rt, 0); + + if (error == 0 rt != NULL) { + RT_LOCK(rt); + ((struct sockaddr_dl *)rt-rt_gateway)-sdl_type = + rt-rt_ifp-if_type; + ((struct sockaddr_dl *)rt-rt_gateway)-sdl_index = + rt-rt_ifp-if_index; + RT_REMREF(rt); + RT_UNLOCK(rt); + } else if (error != 0) + log(LOG_INFO, ifa_add_loopback_route: insertion failed\n); + + return (error); +} + +int +ifa_del_loopback_route(struct ifaddr *ifa, struct sockaddr *ia) +{ + int error = 0; + struct rt_addrinfo info; + struct sockaddr_dl null_sdl; + + bzero(null_sdl, sizeof(null_sdl)); + null_sdl.sdl_len = sizeof(null_sdl); + null_sdl.sdl_family = AF_LINK; + null_sdl.sdl_type = ifa-ifa_ifp-if_type; + null_sdl.sdl_index = ifa-ifa_ifp-if_index; + bzero(info, sizeof(info)); + info.rti_flags = ifa-ifa_flags | RTF_HOST | RTF_STATIC; + info.rti_info[RTAX_DST] = ia; + info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)null_sdl; + error = rtrequest1_fib(RTM_DELETE, info, NULL, 0); + + if (error != 0) + log(LOG_INFO, ifa_del_loopback_route: deletion failed\n); + + return (error); +} + /* * XXX: Because sockaddr_dl has deeper structure than the sockaddr * structs used to represent other address families, it is necessary Modified: stable/8/sys/net/if_var.h == --- stable/8/sys/net/if_var.h Tue Sep 15 22:37:17 2009(r197238) +++ stable/8/sys/net/if_var.h Tue Sep 15 22:46:06 2009(r197239) @@ -854,6 +854,9 @@ struct ifnet *ifunit_ref(const char *); void ifq_init(struct ifaltq *, struct ifnet *ifp); void ifq_delete(struct ifaltq *); +intifa_add_loopback_route(struct ifaddr *, struct sockaddr *); +intifa_del_loopback_route(struct ifaddr *, struct sockaddr *); + struct ifaddr *ifa_ifwithaddr(struct sockaddr *); intifa_ifwithaddr_check(struct sockaddr *); struct ifaddr *ifa_ifwithbroadaddr(struct sockaddr *); Modified: stable/8/sys/netinet/in.c == --- stable/8/sys/netinet/in.c Tue Sep 15 22:37:17 2009(r197238) +++ stable/8/sys/netinet/in.c Tue Sep 15 22:46:06 2009(r197239) @@ -827,9 +827,6 @@ in_ifinit(struct ifnet *ifp, struct in_i { register u_long i = ntohl(sin-sin_addr.s_addr); struct sockaddr_in oldaddr; - struct rtentry *rt = NULL; - struct rt_addrinfo info; - static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK}; int s = splimp(), flags = RTF_UP, error = 0; oldaddr = ia-ia_addr; @@ -927,25 +924,9 @@ in_ifinit(struct ifnet *ifp, struct in_i /* * add a loopback route to self */ - if (V_useloopback !(ifp-if_flags IFF_LOOPBACK)) { - bzero(info, sizeof(info)); - info.rti_ifp = V_loif; - info.rti_flags = ia-ia_flags | RTF_HOST | RTF_STATIC; - info.rti_info[RTAX_DST] = (struct sockaddr *)ia-ia_addr; -
Re: svn commit: r197210 - in head/sys: netinet nfsclient
The users who were reporting the NFS mount problems confirm the patch fixes their issues. At the moment I don't know why the patch would break NFS ROOT. I just backed out the change so RC1 can be made but I will continue the investigation. --Qing On Tue, Sep 15, 2009 at 3:55 PM, Rick Macklem rmack...@uoguelph.ca wrote: On Tue, 15 Sep 2009, Bjoern A. Zeeb wrote: On Tue, 15 Sep 2009, Qing Li wrote: Author: qingli Date: Tue Sep 15 01:01:03 2009 New Revision: 197210 URL: http://svn.freebsd.org/changeset/base/197210 Log:  The bootp code installs an interface address and the nfs client  module tries to install the same address again. This extra code  is removed, which was discovered by the removal of a call to  in_ifscrub() in r196714. This call to in_ifscrub is put back here  because the SIOCAIFADDR command can be used to change the prefix  length of an existing alias.  Reviewed by:   kmacy This broke NFS Root for me in the netperf clsuter setup. The NFS Root mount hang for ages (I reset the box after 1 hour). Backing out r197212 and this and it boots just fine again. I don't know diddly about diskless booting and have no setup to test, but if I understood the problem, might something like the following work? rick --- nfsclient/nfs_vfsops.c.sav  2009-09-15 18:39:32.0 -0400 +++ nfsclient/nfs_vfsops.c    2009-09-15 18:41:52.0 -0400 @@ -416,13 +416,14 @@     struct socket *so;     struct vnode *vp;     struct ifreq ir; -    int error; +    int error, doioctl = 1;     u_long l;     char buf[128];     char *cp;  #if defined(BOOTP_NFSROOT) defined(BOOTP)     bootpc_init();      /* use bootp to get nfs_diskless filled in */ +    doioctl = 0;  #elif defined(NFS_ROOT)     nfs_setup_diskless();  #endif @@ -463,9 +464,11 @@             break;     }  #endif -    error = ifioctl(so, SIOCAIFADDR, (caddr_t)nd-myif, td); -    if (error) -        panic(nfs_mountroot: SIOCAIFADDR: %d, error); +    if (doioctl) { +        error = ifioctl(so, SIOCAIFADDR, (caddr_t)nd-myif, td); +        if (error) +            panic(nfs_mountroot: SIOCAIFADDR: %d, error); +    }     if ((cp = getenv(boot.netif.mtu)) != NULL) {         ir.ifr_mtu = strtol(cp, NULL, 10);         bcopy(nd-myif.ifra_name, ir.ifr_name, IFNAMSIZ); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197364 - head/sys/net
Author: qingli Date: Sun Sep 20 17:22:19 2009 New Revision: 197364 URL: http://svn.freebsd.org/changeset/base/197364 Log: A wrong variable is used when setting up the interface address route, which broke source address selection in some code paths. Submitted by: noted by bz Reviewed by: hrs MFC after:immediately Modified: head/sys/net/if.c Modified: head/sys/net/if.c == --- head/sys/net/if.c Sun Sep 20 16:47:56 2009(r197363) +++ head/sys/net/if.c Sun Sep 20 17:22:19 2009(r197364) @@ -1432,9 +1432,9 @@ ifa_add_loopback_route(struct ifaddr *if if (error == 0 rt != NULL) { RT_LOCK(rt); ((struct sockaddr_dl *)rt-rt_gateway)-sdl_type = - rt-rt_ifp-if_type; + ifa-ifa_ifp-if_type; ((struct sockaddr_dl *)rt-rt_gateway)-sdl_index = - rt-rt_ifp-if_index; + ifa-ifa_ifp-if_index; RT_REMREF(rt); RT_UNLOCK(rt); } else if (error != 0) ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197365 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net
Author: qingli Date: Sun Sep 20 17:46:56 2009 New Revision: 197365 URL: http://svn.freebsd.org/changeset/base/197365 Log: MFC r197364 A wrong variable is used when setting up the interface address route, which broke source address selection in some code paths. Submitted by: noted by bz Reviewed by: hrs Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/if.c Modified: stable/8/sys/net/if.c == --- stable/8/sys/net/if.c Sun Sep 20 17:22:19 2009(r197364) +++ stable/8/sys/net/if.c Sun Sep 20 17:46:56 2009(r197365) @@ -1432,9 +1432,9 @@ ifa_add_loopback_route(struct ifaddr *if if (error == 0 rt != NULL) { RT_LOCK(rt); ((struct sockaddr_dl *)rt-rt_gateway)-sdl_type = - rt-rt_ifp-if_type; + ifa-ifa_ifp-if_type; ((struct sockaddr_dl *)rt-rt_gateway)-sdl_index = - rt-rt_ifp-if_index; + ifa-ifa_ifp-if_index; RT_REMREF(rt); RT_UNLOCK(rt); } else if (error != 0) ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197687 - head/sys/net
Author: qingli Date: Thu Oct 1 20:32:29 2009 New Revision: 197687 URL: http://svn.freebsd.org/changeset/base/197687 Log: The flow-table associates TCP/UDP flows and IP destinations with specific routes. When the routing table changes, for example, when a new route with a more specific prefix is inserted into the routing table, the flow-table is not updated to reflect that change. As such existing connections cannot take advantage of the new path. In some cases the path is broken. This patch will update the affected flow-table entries when a more specific route is added. The route entry is properly marked when a route is deleted from the table. In this case, when the flow-table performs a search, the stale entry is updated automatically. Therefore this patch is not necessary for route deletion. Submitted by: simon, phk Reviewed by: bz, kmacy MFC after:3 days Modified: head/sys/net/flowtable.c head/sys/net/flowtable.h head/sys/net/route.c Modified: head/sys/net/flowtable.c == --- head/sys/net/flowtable.cThu Oct 1 20:11:42 2009(r197686) +++ head/sys/net/flowtable.cThu Oct 1 20:32:29 2009(r197687) @@ -830,7 +830,7 @@ fle_free(struct flentry *fle) } static void -flowtable_free_stale(struct flowtable *ft) +flowtable_free_stale(struct flowtable *ft, struct rtentry *rt) { int curbit = 0, count; struct flentry *fle, **flehead, *fleprev; @@ -866,8 +866,14 @@ flowtable_free_stale(struct flowtable *f curbit); } #endif - while (fle != NULL) { - if (!flow_stale(ft, fle)) { + while (fle != NULL) { + if (rt != NULL) { + if (__DEVOLATILE(struct rtentry *, fle-f_rt) != rt) { + fleprev = fle; + fle = fle-f_next; + continue; + } + } else if (!flow_stale(ft, fle)) { fleprev = fle; fle = fle-f_next; continue; @@ -916,6 +922,30 @@ flowtable_free_stale(struct flowtable *f log(LOG_DEBUG, freed %d flow entries\n, count); } +void +flowtable_route_flush(struct flowtable *ft, struct rtentry *rt) +{ + int i; + if (ft-ft_flags FL_PCPU) { + for (i = 0; i = mp_maxid; i++) { + if (CPU_ABSENT(i)) + continue; + + thread_lock(curthread); + sched_bind(curthread, i); + thread_unlock(curthread); + + flowtable_free_stale(ft, rt); + + thread_lock(curthread); + sched_unbind(curthread); + thread_unlock(curthread); + } + } else { + flowtable_free_stale(ft, rt); + } +} + static void flowtable_clean_vnet(void) { @@ -933,14 +963,14 @@ flowtable_clean_vnet(void) sched_bind(curthread, i); thread_unlock(curthread); - flowtable_free_stale(ft); + flowtable_free_stale(ft, NULL); thread_lock(curthread); sched_unbind(curthread); thread_unlock(curthread); } } else { - flowtable_free_stale(ft); + flowtable_free_stale(ft, NULL); } ft = ft-ft_next; } Modified: head/sys/net/flowtable.h == --- head/sys/net/flowtable.hThu Oct 1 20:11:42 2009(r197686) +++ head/sys/net/flowtable.hThu Oct 1 20:32:29 2009(r197687) @@ -51,5 +51,7 @@ struct flowtable *flowtable_alloc(int ne int flowtable_lookup(struct flowtable *ft, struct mbuf *m, struct route *ro, uint32_t fibnum); +void flowtable_route_flush(struct flowtable *ft, struct rtentry *rt); + #endif /* _KERNEL */ #endif Modified: head/sys/net/route.c == --- head/sys/net/route.cThu Oct 1 20:11:42 2009(r197686) +++ head/sys/net/route.cThu Oct 1 20:32:29 2009(r197687) @@ -56,6 +56,7 @@ #include net/if_dl.h #include net/route.h #include net/vnet.h +#include net/flowtable.h #ifdef RADIX_MPATH #include net/radix_mpath.h @@ -996,6 +997,9 @@ rtrequest1_fib(int req, struct rt_addrin { int error = 0, needlock = 0; register struct rtentry *rt; +#ifdef FLOWTABLE + register
Re: svn commit: r197687 - head/sys/net
I misinterpreted the Submitted by: field. I thought I put in the names of persons who reported the bug. Disregard the Submitted by field for this checkin. It's my code. Something breaks, my fault, email me ... -- Qing On Thu, Oct 1, 2009 at 1:32 PM, Qing Li qin...@freebsd.org wrote: Author: qingli Date: Thu Oct  1 20:32:29 2009 New Revision: 197687 URL: http://svn.freebsd.org/changeset/base/197687 Log:  The flow-table associates TCP/UDP flows and IP destinations with  specific routes. When the routing table changes, for example,  when a new route with a more specific prefix is inserted into the  routing table, the flow-table is not updated to reflect that change.  As such existing connections cannot take advantage of the new path.  In some cases the path is broken. This patch will update the affected  flow-table entries when a more specific route is added. The route  entry is properly marked when a route is deleted from the table.  In this case, when the flow-table performs a search, the stale  entry is updated automatically. Therefore this patch is not  necessary for route deletion.  Submitted by: simon, phk  Reviewed by:  bz, kmacy  MFC after:   3 days Modified:  head/sys/net/flowtable.c  head/sys/net/flowtable.h  head/sys/net/route.c Modified: head/sys/net/flowtable.c == --- head/sys/net/flowtable.c   Thu Oct  1 20:11:42 2009     (r197686) +++ head/sys/net/flowtable.c   Thu Oct  1 20:32:29 2009     (r197687) @@ -830,7 +830,7 @@ fle_free(struct flentry *fle)  }  static void -flowtable_free_stale(struct flowtable *ft) +flowtable_free_stale(struct flowtable *ft, struct rtentry *rt)  {     int curbit = 0, count;     struct flentry *fle,  **flehead, *fleprev; @@ -866,8 +866,14 @@ flowtable_free_stale(struct flowtable *f               curbit);         }  #endif -        while (fle != NULL) { -            if (!flow_stale(ft, fle)) { +        while (fle != NULL) { +            if (rt != NULL) { +                if (__DEVOLATILE(struct rtentry *, fle-f_rt) != rt) { +                    fleprev = fle; +                    fle = fle-f_next; +                    continue; +                } +            } else if (!flow_stale(ft, fle)) {                 fleprev = fle;                 fle = fle-f_next;                 continue; @@ -916,6 +922,30 @@ flowtable_free_stale(struct flowtable *f         log(LOG_DEBUG, freed %d flow entries\n, count);  } +void +flowtable_route_flush(struct flowtable *ft, struct rtentry *rt) +{ +    int i; +    if (ft-ft_flags FL_PCPU) { +        for (i = 0; i = mp_maxid; i++) { +            if (CPU_ABSENT(i)) +                continue; + +            thread_lock(curthread); +            sched_bind(curthread, i); +            thread_unlock(curthread); + +            flowtable_free_stale(ft, rt); + +            thread_lock(curthread); +            sched_unbind(curthread); +            thread_unlock(curthread); +        } +    } else { +        flowtable_free_stale(ft, rt); +    } +} +  static void  flowtable_clean_vnet(void)  { @@ -933,14 +963,14 @@ flowtable_clean_vnet(void)                 sched_bind(curthread, i);                 thread_unlock(curthread); -                flowtable_free_stale(ft); +                flowtable_free_stale(ft, NULL);                 thread_lock(curthread);                 sched_unbind(curthread);                 thread_unlock(curthread);             }         } else { -            flowtable_free_stale(ft); +            flowtable_free_stale(ft, NULL);         }         ft = ft-ft_next;     } Modified: head/sys/net/flowtable.h == --- head/sys/net/flowtable.h   Thu Oct  1 20:11:42 2009     (r197686) +++ head/sys/net/flowtable.h   Thu Oct  1 20:32:29 2009     (r197687) @@ -51,5 +51,7 @@ struct flowtable *flowtable_alloc(int ne  int flowtable_lookup(struct flowtable *ft, struct mbuf *m,   struct route *ro, uint32_t fibnum); +void flowtable_route_flush(struct flowtable *ft, struct rtentry *rt); +  #endif /* _KERNEL */  #endif Modified: head/sys/net/route.c == --- head/sys/net/route.c     Thu Oct  1 20:11:42 2009     (r197686) +++ head/sys/net/route.c     Thu Oct  1 20:32:29 2009
svn commit: r197695 - head/sys/netinet
Author: qingli Date: Fri Oct 2 01:34:55 2009 New Revision: 197695 URL: http://svn.freebsd.org/changeset/base/197695 Log: Previously, if an address alias is configured on an interface, and this address alias has a prefix matching that of another address configured on the same interface, then the ARP entry for the alias is not deleted from the ARP table when that address alias is removed. This patch fixes the aforementioned issue. PR: kern/139113 MFC after:3 days Modified: head/sys/netinet/in.c Modified: head/sys/netinet/in.c == --- head/sys/netinet/in.c Fri Oct 2 01:07:28 2009(r197694) +++ head/sys/netinet/in.c Fri Oct 2 01:34:55 2009(r197695) @@ -1060,6 +1060,8 @@ in_scrubprefix(struct in_ifaddr *target) !(target-ia_ifp-if_flags IFF_LOOPBACK)) { error = ifa_del_loopback_route((struct ifaddr *)target, (struct sockaddr *)target-ia_addr); + /* remove arp cache */ + arp_ifscrub(target-ia_ifp, IA_SIN(target)-sin_addr.s_addr); } if ((target-ia_flags IFA_ROUTE) == 0) { @@ -1082,8 +1084,6 @@ in_scrubprefix(struct in_ifaddr *target) prefix = target-ia_addr.sin_addr; mask = target-ia_sockmask.sin_addr; prefix.s_addr = mask.s_addr; - /* remove arp cache */ - arp_ifscrub(target-ia_ifp, IA_SIN(target)-sin_addr.s_addr); } IN_IFADDR_RLOCK(); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197696 - head/sys/netinet
Author: qingli Date: Fri Oct 2 01:45:11 2009 New Revision: 197696 URL: http://svn.freebsd.org/changeset/base/197696 Log: Remove a log message from production code. This log message can be triggered by a misconfigured host that is sending out gratuious ARPs. This log message can also be triggered during a network renumbering event when multiple prefixes co-exist on a single network segment. MFC after:immediately Modified: head/sys/netinet/in.c Modified: head/sys/netinet/in.c == --- head/sys/netinet/in.c Fri Oct 2 01:34:55 2009(r197695) +++ head/sys/netinet/in.c Fri Oct 2 01:45:11 2009(r197696) @@ -1327,8 +1327,10 @@ in_lltable_rtcheck(struct ifnet *ifp, co /* XXX rtalloc1 should take a const param */ rt = rtalloc1(__DECONST(struct sockaddr *, l3addr), 0, 0); if (rt == NULL || (rt-rt_flags RTF_GATEWAY) || rt-rt_ifp != ifp) { +#ifdef DIAGNOSTICS log(LOG_INFO, IPv4 address: \%s\ is not on the network\n, inet_ntoa(((const struct sockaddr_in *)l3addr)-sin_addr)); +#endif if (rt != NULL) RTFREE_LOCKED(rt); return (EINVAL); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r197687 - head/sys/net
I believe this patch will fix your issue. In fact two other users of openvpn reports the exact same problem symptom. Please give it a try and let me know how it works out for you. -- Qing On Thu, Oct 1, 2009 at 11:22 PM, Tom Judge t...@tomjudge.com wrote: Qing Li wrote: Author: qingli Date: Thu Oct  1 20:32:29 2009 New Revision: 197687 URL: http://svn.freebsd.org/changeset/base/197687 Log:  The flow-table associates TCP/UDP flows and IP destinations with  specific routes. When the routing table changes, for example,  when a new route with a more specific prefix is inserted into the  routing table, the flow-table is not updated to reflect that change.  As such existing connections cannot take advantage of the new path.  In some cases the path is broken. This patch will update the affected  flow-table entries when a more specific route is added. The route  entry is properly marked when a route is deleted from the table.  In this case, when the flow-table performs a search, the stale  entry is updated automatically. Therefore this patch is not  necessary for route deletion. Hi, Will this fix the issue that I see visualising  its self as packet loss over a VPN tunnel? The tunnel is an openvpn (tun mode) tunnel providing a route to 192.168.201.0/24 however when I ping an address in this network with flowtable enabled I see 2-3 out of every 5-6 packets end up being sent out of bge0 (IP 172.17.XX.XX/23 GW 172.17.XX.1) to the default gateway (which responds with destination host unreachable) rather than down tun0. Thanks Tom ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197810 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net
Author: qingli Date: Tue Oct 6 18:47:02 2009 New Revision: 197810 URL: http://svn.freebsd.org/changeset/base/197810 Log: MFC r197687 The flow-table associates TCP/UDP flows and IP destinations with specific routes. When the routing table changes, for example, when a new route with a more specific prefix is inserted into the routing table, the flow-table is not updated to reflect that change. As such existing connections cannot take advantage of the new path. In some cases the path is broken. This patch will update the affected flow-table entries when a more specific route is added. The route entry is properly marked when a route is deleted from the table. In this case, when the flow-table performs a search, the stale entry is updated automatically. Therefore this patch is not necessary for route deletion. Reviewed by: bz, kmacy Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/flowtable.c stable/8/sys/net/flowtable.h stable/8/sys/net/route.c Modified: stable/8/sys/net/flowtable.c == --- stable/8/sys/net/flowtable.cTue Oct 6 17:33:00 2009 (r197809) +++ stable/8/sys/net/flowtable.cTue Oct 6 18:47:02 2009 (r197810) @@ -830,7 +830,7 @@ fle_free(struct flentry *fle) } static void -flowtable_free_stale(struct flowtable *ft) +flowtable_free_stale(struct flowtable *ft, struct rtentry *rt) { int curbit = 0, count; struct flentry *fle, **flehead, *fleprev; @@ -866,8 +866,14 @@ flowtable_free_stale(struct flowtable *f curbit); } #endif - while (fle != NULL) { - if (!flow_stale(ft, fle)) { + while (fle != NULL) { + if (rt != NULL) { + if (__DEVOLATILE(struct rtentry *, fle-f_rt) != rt) { + fleprev = fle; + fle = fle-f_next; + continue; + } + } else if (!flow_stale(ft, fle)) { fleprev = fle; fle = fle-f_next; continue; @@ -916,6 +922,30 @@ flowtable_free_stale(struct flowtable *f log(LOG_DEBUG, freed %d flow entries\n, count); } +void +flowtable_route_flush(struct flowtable *ft, struct rtentry *rt) +{ + int i; + if (ft-ft_flags FL_PCPU) { + for (i = 0; i = mp_maxid; i++) { + if (CPU_ABSENT(i)) + continue; + + thread_lock(curthread); + sched_bind(curthread, i); + thread_unlock(curthread); + + flowtable_free_stale(ft, rt); + + thread_lock(curthread); + sched_unbind(curthread); + thread_unlock(curthread); + } + } else { + flowtable_free_stale(ft, rt); + } +} + static void flowtable_clean_vnet(void) { @@ -933,14 +963,14 @@ flowtable_clean_vnet(void) sched_bind(curthread, i); thread_unlock(curthread); - flowtable_free_stale(ft); + flowtable_free_stale(ft, NULL); thread_lock(curthread); sched_unbind(curthread); thread_unlock(curthread); } } else { - flowtable_free_stale(ft); + flowtable_free_stale(ft, NULL); } ft = ft-ft_next; } Modified: stable/8/sys/net/flowtable.h == --- stable/8/sys/net/flowtable.hTue Oct 6 17:33:00 2009 (r197809) +++ stable/8/sys/net/flowtable.hTue Oct 6 18:47:02 2009 (r197810) @@ -51,5 +51,7 @@ struct flowtable *flowtable_alloc(int ne int flowtable_lookup(struct flowtable *ft, struct mbuf *m, struct route *ro, uint32_t fibnum); +void flowtable_route_flush(struct flowtable *ft, struct rtentry *rt); + #endif /* _KERNEL */ #endif Modified: stable/8/sys/net/route.c == --- stable/8/sys/net/route.cTue Oct 6 17:33:00 2009(r197809) +++ stable/8/sys/net/route.cTue Oct 6 18:47:02 2009
svn commit: r197811 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet
Author: qingli Date: Tue Oct 6 19:44:44 2009 New Revision: 197811 URL: http://svn.freebsd.org/changeset/base/197811 Log: MFC 197695 Previously, if an address alias is configured on an interface, and this address alias has a prefix matching that of another address configured on the same interface, then the ARP entry for the alias is not deleted from the ARP table when that address alias is removed. This patch fixes the aforementioned issue. PR: kern/139113 Reviewed by: bz Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet/in.c Modified: stable/8/sys/netinet/in.c == --- stable/8/sys/netinet/in.c Tue Oct 6 18:47:02 2009(r197810) +++ stable/8/sys/netinet/in.c Tue Oct 6 19:44:44 2009(r197811) @@ -1060,6 +1060,8 @@ in_scrubprefix(struct in_ifaddr *target) !(target-ia_ifp-if_flags IFF_LOOPBACK)) { error = ifa_del_loopback_route((struct ifaddr *)target, (struct sockaddr *)target-ia_addr); + /* remove arp cache */ + arp_ifscrub(target-ia_ifp, IA_SIN(target)-sin_addr.s_addr); } if ((target-ia_flags IFA_ROUTE) == 0) { @@ -1082,8 +1084,6 @@ in_scrubprefix(struct in_ifaddr *target) prefix = target-ia_addr.sin_addr; mask = target-ia_sockmask.sin_addr; prefix.s_addr = mask.s_addr; - /* remove arp cache */ - arp_ifscrub(target-ia_ifp, IA_SIN(target)-sin_addr.s_addr); } IN_IFADDR_RLOCK(); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197813 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet
Author: qingli Date: Tue Oct 6 20:33:02 2009 New Revision: 197813 URL: http://svn.freebsd.org/changeset/base/197813 Log: MFC r197696 Remove a log message from production code. This log message can be triggered by a misconfigured host that is sending out gratuious ARPs. This log message can also be triggered during a network renumbering event when multiple prefixes co-exist on a single network segment. Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet/in.c Modified: stable/8/sys/netinet/in.c == --- stable/8/sys/netinet/in.c Tue Oct 6 20:19:16 2009(r197812) +++ stable/8/sys/netinet/in.c Tue Oct 6 20:33:02 2009(r197813) @@ -1327,8 +1327,10 @@ in_lltable_rtcheck(struct ifnet *ifp, co /* XXX rtalloc1 should take a const param */ rt = rtalloc1(__DECONST(struct sockaddr *, l3addr), 0, 0); if (rt == NULL || (rt-rt_flags RTF_GATEWAY) || rt-rt_ifp != ifp) { +#ifdef DIAGNOSTICS log(LOG_INFO, IPv4 address: \%s\ is not on the network\n, inet_ntoa(((const struct sockaddr_in *)l3addr)-sin_addr)); +#endif if (rt != NULL) RTFREE_LOCKED(rt); return (EINVAL); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r198111 - head/sys/netinet
Author: qingli Date: Thu Oct 15 06:12:04 2009 New Revision: 198111 URL: http://svn.freebsd.org/changeset/base/198111 Log: This patch fixes the following issues in the ARP operation: 1. There is a regression issue in the ARP code. The incomplete ARP entry was timing out too quickly (1 second timeout), as such, a new entry is created each time arpresolve() is called. Therefore the maximum attempts made is always 1. Consequently the error code returned to the application is always 0. 2. Set the expiration of each incomplete entry to a 20-second lifetime. 3. Return incomplete entries to the application. Reviewed by: kmacy MFC after:3 days Modified: head/sys/netinet/if_ether.c head/sys/netinet/in.c Modified: head/sys/netinet/if_ether.c == --- head/sys/netinet/if_ether.c Thu Oct 15 06:02:37 2009(r198110) +++ head/sys/netinet/if_ether.c Thu Oct 15 06:12:04 2009(r198111) @@ -88,11 +88,14 @@ VNET_DEFINE(int, useloopback) = 1; /* us /* timer values */ static VNET_DEFINE(int, arpt_keep) = (20*60); /* once resolved, good for 20 * minutes */ +static VNET_DEFINE(int, arpt_down) = 20; /* keep incomplete entries for + * 20 seconds */ static VNET_DEFINE(int, arp_maxtries) = 5; static VNET_DEFINE(int, arp_proxyall); static VNET_DEFINE(struct arpstat, arpstat); /* ARP statistics, see if_arp.h */ #defineV_arpt_keep VNET(arpt_keep) +#defineV_arpt_down VNET(arpt_down) #defineV_arp_maxtries VNET(arp_maxtries) #defineV_arp_proxyall VNET(arp_proxyall) #defineV_arpstat VNET(arpstat) @@ -309,7 +312,7 @@ retry: } if ((la-la_flags LLE_VALID) - ((la-la_flags LLE_STATIC) || la-la_expire time_uptime)) { + ((la-la_flags LLE_STATIC) || la-la_expire time_second)) { bcopy(la-ll_addr, desten, ifp-if_addrlen); /* * If entry has an expiry time and it is approaching, @@ -317,7 +320,7 @@ retry: * arpt_down interval. */ if (!(la-la_flags LLE_STATIC) - time_uptime + la-la_preempt la-la_expire) { + time_second + la-la_preempt la-la_expire) { arprequest(ifp, NULL, SIN(dst)-sin_addr, IF_LLADDR(ifp)); @@ -337,7 +340,7 @@ retry: goto done; } - renew = (la-la_asked == 0 || la-la_expire != time_uptime); + renew = (la-la_asked == 0 || la-la_expire != time_second); if ((renew || m != NULL) (flags LLE_EXCLUSIVE) == 0) { flags |= LLE_EXCLUSIVE; LLE_RUNLOCK(la); @@ -370,12 +373,12 @@ retry: error = EWOULDBLOCK;/* First request. */ else error = - (rt0-rt_flags RTF_GATEWAY) ? EHOSTDOWN : EHOSTUNREACH; + (rt0-rt_flags RTF_GATEWAY) ? EHOSTUNREACH : EHOSTDOWN; if (renew) { LLE_ADDREF(la); - la-la_expire = time_uptime; - callout_reset(la-la_timer, hz, arptimer, la); + la-la_expire = time_second; + callout_reset(la-la_timer, hz * V_arpt_down, arptimer, la); la-la_asked++; LLE_WUNLOCK(la); arprequest(ifp, NULL, SIN(dst)-sin_addr, @@ -687,7 +690,7 @@ match: EVENTHANDLER_INVOKE(arp_update_event, la); if (!(la-la_flags LLE_STATIC)) { - la-la_expire = time_uptime + V_arpt_keep; + la-la_expire = time_second + V_arpt_keep; callout_reset(la-la_timer, hz * V_arpt_keep, arptimer, la); } Modified: head/sys/netinet/in.c == --- head/sys/netinet/in.c Thu Oct 15 06:02:37 2009(r198110) +++ head/sys/netinet/in.c Thu Oct 15 06:12:04 2009(r198111) @@ -1440,7 +1440,7 @@ in_lltable_dump(struct lltable *llt, str struct sockaddr_dl *sdl; /* skip deleted entries */ - if ((lle-la_flags (LLE_DELETED|LLE_VALID)) != LLE_VALID) + if ((lle-la_flags LLE_DELETED) == LLE_DELETED) continue; /* Skip if jailed and not a valid IP of the prison. */ if (prison_if(wr-td-td_ucred, L3_ADDR(lle)) != 0) @@ -1472,10 +1472,15 @@ in_lltable_dump(struct lltable *llt, str sdl = arpc.sdl; sdl-sdl_family = AF_LINK; sdl-sdl_len
Re: svn commit: r198111 - head/sys/netinet
Forgot to mention the return code was incorrect. The function was returning EHOSTUNEACH when it should be returning EHOSTDOWN. This is also fixed by this patch. -- Qing On Wed, Oct 14, 2009 at 11:12 PM, Qing Li qin...@freebsd.org wrote: Author: qingli Date: Thu Oct 15 06:12:04 2009 New Revision: 198111 URL: http://svn.freebsd.org/changeset/base/198111 Log:  This patch fixes the following issues in the ARP operation:  1. There is a regression issue in the ARP code. The incomplete   ARP entry was timing out too quickly (1 second timeout), as   such, a new entry is created each time arpresolve() is called.   Therefore the maximum attempts made is always 1. Consequently   the error code returned to the application is always 0.  2. Set the expiration of each incomplete entry to a 20-second   lifetime.  3. Return incomplete entries to the application.  Reviewed by:  kmacy  MFC after:   3 days Modified:  head/sys/netinet/if_ether.c  head/sys/netinet/in.c Modified: head/sys/netinet/if_ether.c == --- head/sys/netinet/if_ether.c Thu Oct 15 06:02:37 2009     (r198110) +++ head/sys/netinet/if_ether.c Thu Oct 15 06:12:04 2009     (r198111) @@ -88,11 +88,14 @@ VNET_DEFINE(int, useloopback) = 1;  /* us  /* timer values */  static VNET_DEFINE(int, arpt_keep) = (20*60);  /* once resolved, good for 20                         * minutes */ +static VNET_DEFINE(int, arpt_down) = 20;    /* keep incomplete entries for +                        * 20 seconds */  static VNET_DEFINE(int, arp_maxtries) = 5;  static VNET_DEFINE(int, arp_proxyall);  static VNET_DEFINE(struct arpstat, arpstat);  /* ARP statistics, see if_arp.h */  #define     V_arpt_keep       VNET(arpt_keep) +#define     V_arpt_down       VNET(arpt_down)  #define     V_arp_maxtries      VNET(arp_maxtries)  #define     V_arp_proxyall      VNET(arp_proxyall)  #define     V_arpstat        VNET(arpstat) @@ -309,7 +312,7 @@ retry:     }     if ((la-la_flags LLE_VALID) -      ((la-la_flags LLE_STATIC) || la-la_expire time_uptime)) { +      ((la-la_flags LLE_STATIC) || la-la_expire time_second)) {         bcopy(la-ll_addr, desten, ifp-if_addrlen);         /*         * If entry has an expiry time and it is approaching, @@ -317,7 +320,7 @@ retry:         * arpt_down interval.         */         if (!(la-la_flags LLE_STATIC) -          time_uptime + la-la_preempt la-la_expire) { +          time_second + la-la_preempt la-la_expire) {             arprequest(ifp, NULL,               SIN(dst)-sin_addr, IF_LLADDR(ifp)); @@ -337,7 +340,7 @@ retry:         goto done;     } -    renew = (la-la_asked == 0 || la-la_expire != time_uptime); +    renew = (la-la_asked == 0 || la-la_expire != time_second);     if ((renew || m != NULL) (flags LLE_EXCLUSIVE) == 0) {         flags |= LLE_EXCLUSIVE;         LLE_RUNLOCK(la); @@ -370,12 +373,12 @@ retry:         error = EWOULDBLOCK;   /* First request. */     else         error = -          (rt0-rt_flags RTF_GATEWAY) ? EHOSTDOWN : EHOSTUNREACH; +            (rt0-rt_flags RTF_GATEWAY) ? EHOSTUNREACH : EHOSTDOWN;     if (renew) {         LLE_ADDREF(la); -        la-la_expire = time_uptime; -        callout_reset(la-la_timer, hz, arptimer, la); +        la-la_expire = time_second; +        callout_reset(la-la_timer, hz * V_arpt_down, arptimer, la);         la-la_asked++;         LLE_WUNLOCK(la);         arprequest(ifp, NULL, SIN(dst)-sin_addr, @@ -687,7 +690,7 @@ match:         EVENTHANDLER_INVOKE(arp_update_event, la);         if (!(la-la_flags LLE_STATIC)) { -            la-la_expire = time_uptime + V_arpt_keep; +            la-la_expire = time_second + V_arpt_keep;             callout_reset(la-la_timer, hz * V_arpt_keep,               arptimer, la);         } Modified: head/sys/netinet/in.c == --- head/sys/netinet/in.c    Thu Oct 15 06:02:37 2009     (r198110) +++ head/sys/netinet/in.c    Thu Oct 15 06:12:04 2009     (r198111) @@ -1440,7 +1440,7 @@ in_lltable_dump(struct lltable *llt, str             struct sockaddr_dl *sdl;             /* skip deleted entries */ -            if ((lle-la_flags (LLE_DELETED|LLE_VALID)) != LLE_VALID) +            if ((lle-la_flags LLE_DELETED) == LLE_DELETED)                 continue;             /* Skip if jailed and not a valid IP of the prison
svn commit: r198298 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet
Author: qingli Date: Tue Oct 20 17:44:50 2009 New Revision: 198298 URL: http://svn.freebsd.org/changeset/base/198298 Log: MFC r198111 This patch fixes the following issues in the ARP operation: 1. There is a regression issue in the ARP code. The incomplete ARP entry was timing out too quickly (1 second timeout), as such, a new entry is created each time arpresolve() is called. Therefore the maximum attempts made is always 1. Consequently the error code returned to the application is always 0. 2. Set the expiration of each incomplete entry to a 20-second lifetime. 3. Return incomplete entries to the application. 4. The return error code was incorrect. Reviewed by: kmacy Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet/if_ether.c stable/8/sys/netinet/in.c Modified: stable/8/sys/netinet/if_ether.c == --- stable/8/sys/netinet/if_ether.c Tue Oct 20 16:46:39 2009 (r198297) +++ stable/8/sys/netinet/if_ether.c Tue Oct 20 17:44:50 2009 (r198298) @@ -87,10 +87,13 @@ VNET_DEFINE(int, useloopback) = 1; /* us /* timer values */ static VNET_DEFINE(int, arpt_keep) = (20*60); /* once resolved, good for 20 * minutes */ +static VNET_DEFINE(int, arpt_down) = 20; /* keep incomplete entries for + * 20 seconds */ static VNET_DEFINE(int, arp_maxtries) = 5; static VNET_DEFINE(int, arp_proxyall); #defineV_arpt_keep VNET(arpt_keep) +#defineV_arpt_down VNET(arpt_down) #defineV_arp_maxtries VNET(arp_maxtries) #defineV_arp_proxyall VNET(arp_proxyall) @@ -299,7 +302,7 @@ retry: } if ((la-la_flags LLE_VALID) - ((la-la_flags LLE_STATIC) || la-la_expire time_uptime)) { + ((la-la_flags LLE_STATIC) || la-la_expire time_second)) { bcopy(la-ll_addr, desten, ifp-if_addrlen); /* * If entry has an expiry time and it is approaching, @@ -307,7 +310,7 @@ retry: * arpt_down interval. */ if (!(la-la_flags LLE_STATIC) - time_uptime + la-la_preempt la-la_expire) { + time_second + la-la_preempt la-la_expire) { arprequest(ifp, NULL, SIN(dst)-sin_addr, IF_LLADDR(ifp)); @@ -327,7 +330,7 @@ retry: goto done; } - renew = (la-la_asked == 0 || la-la_expire != time_uptime); + renew = (la-la_asked == 0 || la-la_expire != time_second); if ((renew || m != NULL) (flags LLE_EXCLUSIVE) == 0) { flags |= LLE_EXCLUSIVE; LLE_RUNLOCK(la); @@ -358,12 +361,12 @@ retry: error = EWOULDBLOCK;/* First request. */ else error = - (rt0-rt_flags RTF_GATEWAY) ? EHOSTDOWN : EHOSTUNREACH; + (rt0-rt_flags RTF_GATEWAY) ? EHOSTUNREACH : EHOSTDOWN; if (renew) { LLE_ADDREF(la); - la-la_expire = time_uptime; - callout_reset(la-la_timer, hz, arptimer, la); + la-la_expire = time_second; + callout_reset(la-la_timer, hz * V_arpt_down, arptimer, la); la-la_asked++; LLE_WUNLOCK(la); arprequest(ifp, NULL, SIN(dst)-sin_addr, @@ -668,7 +671,7 @@ match: la-la_flags |= LLE_VALID; if (!(la-la_flags LLE_STATIC)) { - la-la_expire = time_uptime + V_arpt_keep; + la-la_expire = time_second + V_arpt_keep; callout_reset(la-la_timer, hz * V_arpt_keep, arptimer, la); } Modified: stable/8/sys/netinet/in.c == --- stable/8/sys/netinet/in.c Tue Oct 20 16:46:39 2009(r198297) +++ stable/8/sys/netinet/in.c Tue Oct 20 17:44:50 2009(r198298) @@ -1439,7 +1439,7 @@ in_lltable_dump(struct lltable *llt, str struct sockaddr_dl *sdl; /* skip deleted entries */ - if ((lle-la_flags (LLE_DELETED|LLE_VALID)) != LLE_VALID) + if ((lle-la_flags LLE_DELETED) == LLE_DELETED) continue; /* Skip if jailed and not a valid IP of the prison. */ if
svn commit: r198301 - head/sys/netinet
Author: qingli Date: Tue Oct 20 17:55:42 2009 New Revision: 198301 URL: http://svn.freebsd.org/changeset/base/198301 Log: In the ARP callout timer expiration function, the current time_second is compared against the entry expiration time value (that was set based on time_second) to check if the current time is larger than the set expiration time. Due to the +/- timer granularity value, the comparison returns false, causing the alternative code to be executed. The alternative code path freed the memory without removing that entry from the table list, causing a use-after-free bug. Reviewed by: discussed with kmacy MFC after:immediately Verified by: rnoland, yongari Modified: head/sys/netinet/if_ether.c Modified: head/sys/netinet/if_ether.c == --- head/sys/netinet/if_ether.c Tue Oct 20 17:50:36 2009(r198300) +++ head/sys/netinet/if_ether.c Tue Oct 20 17:55:42 2009(r198301) @@ -175,18 +175,18 @@ arptimer(void *arg) CURVNET_SET(ifp-if_vnet); IF_AFDATA_LOCK(ifp); LLE_WLOCK(lle); - if (((lle-la_flags LLE_DELETED) || - (time_second = lle-la_expire)) - (!callout_pending(lle-la_timer) + if ((!callout_pending(lle-la_timer) callout_active(lle-la_timer))) { (void) llentry_free(lle); ARPSTAT_INC(timeouts); - } else { - /* -* Still valid, just drop our reference -*/ - LLE_FREE_LOCKED(lle); + } +#ifdef DIAGNOSTICS + else { + struct sockaddr *l3addr = L3_ADDR(lle); + log(LOG_INFO, arptimer issue: %p, IPv4 address: \%s\\n, lle, + inet_ntoa(((const struct sockaddr_in *)l3addr)-sin_addr)); } +#endif IF_AFDATA_UNLOCK(ifp); CURVNET_RESTORE(); } @@ -377,7 +377,7 @@ retry: if (renew) { LLE_ADDREF(la); - la-la_expire = time_second; + la-la_expire = time_second + V_arpt_down; callout_reset(la-la_timer, hz * V_arpt_down, arptimer, la); la-la_asked++; LLE_WUNLOCK(la); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r198306 - head/sys/net
Author: qingli Date: Tue Oct 20 21:27:03 2009 New Revision: 198306 URL: http://svn.freebsd.org/changeset/base/198306 Log: The flow-table function flowtable_route_flush() may be called during system initialization time. Since the flow-table is designed to maintain per CPU flow cache, the existing code did not check whether smp_started is true before calling sched_bind() and sched_unbind(), which triggers a page fault. Reviewed by: jeff MFC after:immediately Modified: head/sys/net/flowtable.c Modified: head/sys/net/flowtable.c == --- head/sys/net/flowtable.cTue Oct 20 21:08:32 2009(r198305) +++ head/sys/net/flowtable.cTue Oct 20 21:27:03 2009(r198306) @@ -930,16 +930,20 @@ flowtable_route_flush(struct flowtable * for (i = 0; i = mp_maxid; i++) { if (CPU_ABSENT(i)) continue; - - thread_lock(curthread); - sched_bind(curthread, i); - thread_unlock(curthread); + + if (smp_started == 1) { + thread_lock(curthread); + sched_bind(curthread, i); + thread_unlock(curthread); + } flowtable_free_stale(ft, rt); - thread_lock(curthread); - sched_unbind(curthread); - thread_unlock(curthread); + if (smp_started == 1) { + thread_lock(curthread); + sched_unbind(curthread); + thread_unlock(curthread); + } } } else { flowtable_free_stale(ft, rt); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r198308 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet
Author: qingli Date: Tue Oct 20 21:36:56 2009 New Revision: 198308 URL: http://svn.freebsd.org/changeset/base/198308 Log: MFC 198301 In the ARP callout timer expiration function, the current time_second is compared against the entry expiration time value (that was set based on time_second) to check if the current time is larger than the set expiration time. Due to the +/- timer granularity value, the comparison returns false, causing the alternative code to be executed. The alternative code path freed the memory without removing that entry from the table list, causing a use-after-free bug. Reviewed by: discussed with kmacy Approved by: re Verified by: rnoland, yongari Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet/if_ether.c Modified: stable/8/sys/netinet/if_ether.c == --- stable/8/sys/netinet/if_ether.c Tue Oct 20 21:29:46 2009 (r198307) +++ stable/8/sys/netinet/if_ether.c Tue Oct 20 21:36:56 2009 (r198308) @@ -168,17 +168,17 @@ arptimer(void *arg) ifp = lle-lle_tbl-llt_ifp; IF_AFDATA_LOCK(ifp); LLE_WLOCK(lle); - if (((lle-la_flags LLE_DELETED) - || (time_second = lle-la_expire)) -(!callout_pending(lle-la_timer) - callout_active(lle-la_timer))) + if ((!callout_pending(lle-la_timer) + callout_active(lle-la_timer))) { (void) llentry_free(lle); + } +#ifdef DIAGNOSTICS else { - /* -* Still valid, just drop our reference -*/ - LLE_FREE_LOCKED(lle); + struct sockaddr *l3addr = L3_ADDR(lle); + log(LOG_INFO, arptimer issue: %p, IPv4 address: \%s\\n, lle, + inet_ntoa(((const struct sockaddr_in *)l3addr)-sin_addr)); } +#endif IF_AFDATA_UNLOCK(ifp); } @@ -365,7 +365,7 @@ retry: if (renew) { LLE_ADDREF(la); - la-la_expire = time_second; + la-la_expire = time_second + V_arpt_down; callout_reset(la-la_timer, hz * V_arpt_down, arptimer, la); la-la_asked++; LLE_WUNLOCK(la); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r198301 - head/sys/netinet
I believe this patch will fix your crash. -- Qing On Wed, Oct 21, 2009 at 12:58 AM, Robert Watson rwat...@freebsd.org wrote: On Tue, 20 Oct 2009, Qing Li wrote:  In the ARP callout timer expiration function, the current time_second  is compared against the entry expiration time value (that was set based  on time_second) to check if the current time is larger than the set  expiration time. Due to the +/- timer granularity value, the comparison  returns false, causing the alternative code to be executed. The  alternative code path freed the memory without removing that entry  from the table list, causing a use-after-free bug.  Reviewed by:  discussed with kmacy  MFC after:   immediately  Verified by:  rnoland, yongari Could this be the same problem I ran into overnight on an 18 October kernel: Fatal trap 12: page fault while in kernel mode cpuid = 0; apic id = 00 fault virtual address  = 0x7572749f fault code        = supervisor read, page not present instruction pointer   = 0x20:0xc09c0551 stack pointer      = 0x28:0xc43f6ab4 frame pointer      = 0x28:0xc43f6adc code segment       = base 0x0, limit 0xf, type 0x1b             = DPL 0, pres 1, def32 1, gran 1 processor eflags     = interrupt enabled, resume, IOPL = 0 current process     = 0 (em0 taskq) #9  0xc0be731b in calltrap () at ../../../i386/i386/exception.s:165 #10 0xc09c0551 in in_lltable_lookup (llt=0xc4955200, flags=8192,   l3addr=0xc43f6b60) at ../../../netinet/in.c:1361 #11 0xc09b8ea7 in arpintr (m=0xc48dcd00) at if_llatbl.h:202 #12 0xc096f899 in netisr_dispatch_src (proto=7, source=0, m=0xc48dcd00)   at ../../../net/netisr.c:917 #13 0xc096fb30 in netisr_dispatch (proto=7, m=0xc48dcd00)   at ../../../net/netisr.c:1004 #14 0xc0967c11 in ether_demux (ifp=0xc470b400, m=0xc48dcd00)   at ../../../net/if_ethersubr.c:895 #15 0xc0968163 in ether_input (ifp=0xc470b400, m=0xc48dcd00)   at ../../../net/if_ethersubr.c:754 #16 0xc063bcaa in em_rxeof (adapter=0xc470d000, count=99)   at ../../../dev/e1000/if_em.c:4610 #17 0xc063dfc7 in em_handle_rxtx (context=0xc470d000, pending=1)   at ../../../dev/e1000/if_em.c:1763 (kgdb) frame 10 #10 0xc09c0551 in in_lltable_lookup (llt=0xc4955200, flags=8192,   l3addr=0xc43f6b60) at ../../../netinet/in.c:1361 1361       LIST_FOREACH(lle, lleh, lle_next) { (kgdb) list 1356       KASSERT(l3addr-sa_family == AF_INET, 1357         (sin_family %d, l3addr-sa_family)); 1358 1359       hashkey = sin-sin_addr.s_addr; 1360       lleh = llt-lle_head[LLATBL_HASH(hashkey, LLTBL_HASHMASK)]; 1361       LIST_FOREACH(lle, lleh, lle_next) { 1362           struct sockaddr_in *sa2 = (struct sockaddr_in *)L3_ADDR(lle); 1363           if (lle-la_flags LLE_DELETED) 1364               continue; 1365           if (sa2-sin_addr.s_addr == sin-sin_addr.s_addr) (kgdb) print *llt $5 = {llt_link = {sle_next = 0x0}, lle_head = {{lh_first = 0xc760d580}, {    lh_first = 0x0}, {lh_first = 0x0}, {lh_first = 0xc75c3900}, {    lh_first = 0x0} repeats 14 times, {lh_first = 0xc49a8380}, {    lh_first = 0x0}, {lh_first = 0x0}, {lh_first = 0x0}, {lh_first = 0x0}, {    lh_first = 0x0}, {lh_first = 0x0}, {lh_first = 0x0}, {lh_first = 0x0}, {    lh_first = 0x0}, {lh_first = 0xc61be780}, {lh_first = 0x0}, {    lh_first = 0x0}, {lh_first = 0x0}}, llt_af = 2, llt_ifp = 0xc470b400,  llt_new = 0xc09bdd60 in_lltable_new,  llt_free = 0xc09c0490 in_lltable_free,  llt_prefix_free = 0xc09c09b0 in_lltable_prefix_free,  llt_lookup = 0xc09c0510 in_lltable_lookup,  llt_rtcheck = 0xc09bdbe0 in_lltable_rtcheck,  llt_dump = 0xc09bd9c0 in_lltable_dump} (kgdb) print *l3addr $6 = {sa_len = 16 '\020', sa_family = 2 '\002',  sa_data = \000\000??*\001\000\000\000\000\000\000\000} (kgdb) print lle $7 = (struct llentry *) 0x75727473 (kgdb) print lleh $8 = (struct llentries *) 0xc4955210 (kgdb) print *lleh $9 = {lh_first = 0xc75c3900} Your commit was after this kernel, so I'd be quite happy with the answer now fixed but wanted to be sure. Robert Modified:  head/sys/netinet/if_ether.c Modified: head/sys/netinet/if_ether.c == --- head/sys/netinet/if_ether.c Tue Oct 20 17:50:36 2009     (r198300) +++ head/sys/netinet/if_ether.c Tue Oct 20 17:55:42 2009     (r198301) @@ -175,18 +175,18 @@ arptimer(void *arg)     CURVNET_SET(ifp-if_vnet);     IF_AFDATA_LOCK(ifp);     LLE_WLOCK(lle); -    if (((lle-la_flags LLE_DELETED) || -      (time_second = lle-la_expire)) -      (!callout_pending(lle-la_timer) +    if ((!callout_pending(lle-la_timer)       callout_active(lle-la_timer))) {         (void) llentry_free(lle);         ARPSTAT_INC(timeouts); -    } else { -        /* -         * Still valid, just
svn commit: r198371 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net
Author: qingli Date: Thu Oct 22 18:48:25 2009 New Revision: 198371 URL: http://svn.freebsd.org/changeset/base/198371 Log: MFC 198306 The flow-table function flowtable_route_flush() may be called during system initialization time. Since the flow-table is designed to maintain per CPU flow cache, the existing code did not check whether smp_started is true before calling sched_bind() and sched_unbind(), which triggers a page fault. Reviewed by: jeff Approved by: re Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/flowtable.c Modified: stable/8/sys/net/flowtable.c == --- stable/8/sys/net/flowtable.cThu Oct 22 17:36:41 2009 (r198370) +++ stable/8/sys/net/flowtable.cThu Oct 22 18:48:25 2009 (r198371) @@ -930,16 +930,20 @@ flowtable_route_flush(struct flowtable * for (i = 0; i = mp_maxid; i++) { if (CPU_ABSENT(i)) continue; - - thread_lock(curthread); - sched_bind(curthread, i); - thread_unlock(curthread); + + if (smp_started == 1) { + thread_lock(curthread); + sched_bind(curthread, i); + thread_unlock(curthread); + } flowtable_free_stale(ft, rt); - thread_lock(curthread); - sched_unbind(curthread); - thread_unlock(curthread); + if (smp_started == 1) { + thread_lock(curthread); + sched_unbind(curthread); + thread_unlock(curthread); + } } } else { flowtable_free_stale(ft, rt); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r198418 - in head/sys: netinet netinet6
Author: qingli Date: Fri Oct 23 18:27:34 2009 New Revision: 198418 URL: http://svn.freebsd.org/changeset/base/198418 Log: Use the correct option name in the preprocessor command to enable or disable diagnostic messages. Reviewed by: ru MFC after:3 days Modified: head/sys/netinet/if_ether.c head/sys/netinet/in.c head/sys/netinet6/in6.c Modified: head/sys/netinet/if_ether.c == --- head/sys/netinet/if_ether.c Fri Oct 23 17:26:29 2009(r198417) +++ head/sys/netinet/if_ether.c Fri Oct 23 18:27:34 2009(r198418) @@ -180,7 +180,7 @@ arptimer(void *arg) (void) llentry_free(lle); ARPSTAT_INC(timeouts); } -#ifdef DIAGNOSTICS +#ifdef DIAGNOSTIC else { struct sockaddr *l3addr = L3_ADDR(lle); log(LOG_INFO, arptimer issue: %p, IPv4 address: \%s\\n, lle, Modified: head/sys/netinet/in.c == --- head/sys/netinet/in.c Fri Oct 23 17:26:29 2009(r198417) +++ head/sys/netinet/in.c Fri Oct 23 18:27:34 2009(r198418) @@ -1327,7 +1327,7 @@ in_lltable_rtcheck(struct ifnet *ifp, co /* XXX rtalloc1 should take a const param */ rt = rtalloc1(__DECONST(struct sockaddr *, l3addr), 0, 0); if (rt == NULL || (rt-rt_flags RTF_GATEWAY) || rt-rt_ifp != ifp) { -#ifdef DIAGNOSTICS +#ifdef DIAGNOSTIC log(LOG_INFO, IPv4 address: \%s\ is not on the network\n, inet_ntoa(((const struct sockaddr_in *)l3addr)-sin_addr)); #endif @@ -1366,7 +1366,7 @@ in_lltable_lookup(struct lltable *llt, u break; } if (lle == NULL) { -#ifdef DIAGNOSTICS +#ifdef DIAGNOSTIC if (flags LLE_DELETE) log(LOG_INFO, interface address is missing from cache = %p in delete\n, lle); #endif @@ -1401,7 +1401,7 @@ in_lltable_lookup(struct lltable *llt, u lle-la_flags = LLE_DELETED; EVENTHANDLER_INVOKE(arp_update_event, lle); LLE_WUNLOCK(lle); -#ifdef DIAGNOSTICS +#ifdef DIAGNOSTIC log(LOG_INFO, ifaddr cache = %p is deleted\n, lle); #endif } Modified: head/sys/netinet6/in6.c == --- head/sys/netinet6/in6.c Fri Oct 23 17:26:29 2009(r198417) +++ head/sys/netinet6/in6.c Fri Oct 23 18:27:34 2009(r198418) @@ -2437,7 +2437,7 @@ in6_lltable_lookup(struct lltable *llt, LLE_WLOCK(lle); lle-la_flags = LLE_DELETED; LLE_WUNLOCK(lle); -#ifdef DIAGNOSTICS +#ifdef DIAGNOSTIC log(LOG_INFO, ifaddr cache = %p is deleted\n, lle); #endif } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r198566 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net
Author: qingli Date: Wed Oct 28 21:43:16 2009 New Revision: 198566 URL: http://svn.freebsd.org/changeset/base/198566 Log: MFC r198353 Verify smp_started is true before calling sched_bind() and sched_unbind(). Reviewed by: kmacy Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/flowtable.c Modified: stable/8/sys/net/flowtable.c == --- stable/8/sys/net/flowtable.cWed Oct 28 21:41:23 2009 (r198565) +++ stable/8/sys/net/flowtable.cWed Oct 28 21:43:16 2009 (r198566) @@ -963,15 +963,19 @@ flowtable_clean_vnet(void) if (CPU_ABSENT(i)) continue; - thread_lock(curthread); - sched_bind(curthread, i); - thread_unlock(curthread); + if (smp_started == 1) { + thread_lock(curthread); + sched_bind(curthread, i); + thread_unlock(curthread); + } flowtable_free_stale(ft, NULL); - thread_lock(curthread); - sched_unbind(curthread); - thread_unlock(curthread); + if (smp_started == 1) { + thread_lock(curthread); + sched_unbind(curthread); + thread_unlock(curthread); + } } } else { flowtable_free_stale(ft, NULL); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r198567 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci netinet netinet6
Author: qingli Date: Wed Oct 28 21:45:25 2009 New Revision: 198567 URL: http://svn.freebsd.org/changeset/base/198567 Log: MFC r198418 Use the correct option name in the preprocessor command to enable or disable diagnostic messages. Reviewed by: ru Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet/if_ether.c stable/8/sys/netinet/in.c stable/8/sys/netinet6/in6.c Modified: stable/8/sys/netinet/if_ether.c == --- stable/8/sys/netinet/if_ether.c Wed Oct 28 21:43:16 2009 (r198566) +++ stable/8/sys/netinet/if_ether.c Wed Oct 28 21:45:25 2009 (r198567) @@ -172,7 +172,7 @@ arptimer(void *arg) callout_active(lle-la_timer))) { (void) llentry_free(lle); } -#ifdef DIAGNOSTICS +#ifdef DIAGNOSTIC else { struct sockaddr *l3addr = L3_ADDR(lle); log(LOG_INFO, arptimer issue: %p, IPv4 address: \%s\\n, lle, Modified: stable/8/sys/netinet/in.c == --- stable/8/sys/netinet/in.c Wed Oct 28 21:43:16 2009(r198566) +++ stable/8/sys/netinet/in.c Wed Oct 28 21:45:25 2009(r198567) @@ -1327,7 +1327,7 @@ in_lltable_rtcheck(struct ifnet *ifp, co /* XXX rtalloc1 should take a const param */ rt = rtalloc1(__DECONST(struct sockaddr *, l3addr), 0, 0); if (rt == NULL || (rt-rt_flags RTF_GATEWAY) || rt-rt_ifp != ifp) { -#ifdef DIAGNOSTICS +#ifdef DIAGNOSTIC log(LOG_INFO, IPv4 address: \%s\ is not on the network\n, inet_ntoa(((const struct sockaddr_in *)l3addr)-sin_addr)); #endif @@ -1366,7 +1366,7 @@ in_lltable_lookup(struct lltable *llt, u break; } if (lle == NULL) { -#ifdef DIAGNOSTICS +#ifdef DIAGNOSTIC if (flags LLE_DELETE) log(LOG_INFO, interface address is missing from cache = %p in delete\n, lle); #endif @@ -1400,7 +1400,7 @@ in_lltable_lookup(struct lltable *llt, u LLE_WLOCK(lle); lle-la_flags = LLE_DELETED; LLE_WUNLOCK(lle); -#ifdef DIAGNOSTICS +#ifdef DIAGNOSTIC log(LOG_INFO, ifaddr cache = %p is deleted\n, lle); #endif } Modified: stable/8/sys/netinet6/in6.c == --- stable/8/sys/netinet6/in6.c Wed Oct 28 21:43:16 2009(r198566) +++ stable/8/sys/netinet6/in6.c Wed Oct 28 21:45:25 2009(r198567) @@ -2430,7 +2430,7 @@ in6_lltable_lookup(struct lltable *llt, LLE_WLOCK(lle); lle-la_flags = LLE_DELETED; LLE_WUNLOCK(lle); -#ifdef DIAGNOSTICS +#ifdef DIAGNOSTIC log(LOG_INFO, ifaddr cache = %p is deleted\n, lle); #endif } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r198568 - in releng/8.0/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci net
Author: qingli Date: Wed Oct 28 22:00:49 2009 New Revision: 198568 URL: http://svn.freebsd.org/changeset/base/198568 Log: MFC r198353 Verify smp_started is true before calling sched_bind() and sched_unbind(). Reviewed by: kmacy Approved by: re Modified: releng/8.0/sys/ (props changed) releng/8.0/sys/amd64/include/xen/ (props changed) releng/8.0/sys/cddl/contrib/opensolaris/ (props changed) releng/8.0/sys/contrib/dev/acpica/ (props changed) releng/8.0/sys/contrib/pf/ (props changed) releng/8.0/sys/dev/xen/xenpci/ (props changed) releng/8.0/sys/net/flowtable.c Modified: releng/8.0/sys/net/flowtable.c == --- releng/8.0/sys/net/flowtable.c Wed Oct 28 21:45:25 2009 (r198567) +++ releng/8.0/sys/net/flowtable.c Wed Oct 28 22:00:49 2009 (r198568) @@ -963,15 +963,19 @@ flowtable_clean_vnet(void) if (CPU_ABSENT(i)) continue; - thread_lock(curthread); - sched_bind(curthread, i); - thread_unlock(curthread); + if (smp_started == 1) { + thread_lock(curthread); + sched_bind(curthread, i); + thread_unlock(curthread); + } flowtable_free_stale(ft, NULL); - thread_lock(curthread); - sched_unbind(curthread); - thread_unlock(curthread); + if (smp_started == 1) { + thread_lock(curthread); + sched_unbind(curthread); + thread_unlock(curthread); + } } } else { flowtable_free_stale(ft, NULL); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r208553 - in head/sys: net netinet
Author: qingli Date: Tue May 25 20:42:35 2010 New Revision: 208553 URL: http://svn.freebsd.org/changeset/base/208553 Log: This patch fixes the problem where proxy ARP entries cannot be added over the if_ng interface. MFC after:3 days Modified: head/sys/net/if.c head/sys/net/if_var.h head/sys/net/route.c head/sys/net/rtsock.c head/sys/netinet/in.c head/sys/netinet/in_pcb.c head/sys/netinet/ip_options.c head/sys/netinet/ip_output.c Modified: head/sys/net/if.c == --- head/sys/net/if.c Tue May 25 20:35:39 2010(r208552) +++ head/sys/net/if.c Tue May 25 20:42:35 2010(r208553) @@ -1607,7 +1607,7 @@ done: * is most specific found. */ struct ifaddr * -ifa_ifwithnet(struct sockaddr *addr) +ifa_ifwithnet(struct sockaddr *addr, int ignore_ptp) { struct ifnet *ifp; struct ifaddr *ifa; @@ -1639,7 +1639,8 @@ ifa_ifwithnet(struct sockaddr *addr) if (ifa-ifa_addr-sa_family != af) next: continue; - if (af == AF_INET ifp-if_flags IFF_POINTOPOINT) { + if (af == AF_INET + ifp-if_flags IFF_POINTOPOINT !ignore_ptp) { /* * This is a bit broken as it doesn't * take into account that the remote end may Modified: head/sys/net/if_var.h == --- head/sys/net/if_var.h Tue May 25 20:35:39 2010(r208552) +++ head/sys/net/if_var.h Tue May 25 20:42:35 2010(r208553) @@ -873,7 +873,7 @@ struct ifaddr *ifa_ifwithaddr(struct soc intifa_ifwithaddr_check(struct sockaddr *); struct ifaddr *ifa_ifwithbroadaddr(struct sockaddr *); struct ifaddr *ifa_ifwithdstaddr(struct sockaddr *); -struct ifaddr *ifa_ifwithnet(struct sockaddr *); +struct ifaddr *ifa_ifwithnet(struct sockaddr *, int); struct ifaddr *ifa_ifwithroute(int, struct sockaddr *, struct sockaddr *); struct ifaddr *ifa_ifwithroute_fib(int, struct sockaddr *, struct sockaddr *, u_int); Modified: head/sys/net/route.c == --- head/sys/net/route.cTue May 25 20:35:39 2010(r208552) +++ head/sys/net/route.cTue May 25 20:42:35 2010(r208553) @@ -519,7 +519,7 @@ rtredirect_fib(struct sockaddr *dst, } /* verify the gateway is directly reachable */ - if ((ifa = ifa_ifwithnet(gateway)) == NULL) { + if ((ifa = ifa_ifwithnet(gateway, 0)) == NULL) { error = ENETUNREACH; goto out; } @@ -686,7 +686,7 @@ ifa_ifwithroute_fib(int flags, struct so ifa = ifa_ifwithdstaddr(gateway); } if (ifa == NULL) - ifa = ifa_ifwithnet(gateway); + ifa = ifa_ifwithnet(gateway, 0); if (ifa == NULL) { struct rtentry *rt = rtalloc1_fib(gateway, 0, RTF_RNH_LOCKED, fibnum); if (rt == NULL) @@ -797,7 +797,7 @@ rt_getifa_fib(struct rt_addrinfo *info, */ if (info-rti_ifp == NULL ifpaddr != NULL ifpaddr-sa_family == AF_LINK - (ifa = ifa_ifwithnet(ifpaddr)) != NULL) { + (ifa = ifa_ifwithnet(ifpaddr, 0)) != NULL) { info-rti_ifp = ifa-ifa_ifp; ifa_free(ifa); } Modified: head/sys/net/rtsock.c == --- head/sys/net/rtsock.c Tue May 25 20:35:39 2010(r208552) +++ head/sys/net/rtsock.c Tue May 25 20:42:35 2010(r208553) @@ -55,6 +55,7 @@ #include net/if.h #include net/if_dl.h #include net/if_llatbl.h +#include net/if_types.h #include net/netisr.h #include net/raw_cb.h #include net/route.h @@ -673,12 +674,22 @@ route_output(struct mbuf *m, struct sock * another search to retrieve the prefix route of * the local end point of the PPP link. */ - if ((rtm-rtm_flags RTF_ANNOUNCE) - (rt-rt_ifp-if_flags IFF_POINTOPOINT)) { + if (rtm-rtm_flags RTF_ANNOUNCE) { struct sockaddr laddr; - rt_maskedcopy(rt-rt_ifa-ifa_addr, - laddr, - rt-rt_ifa-ifa_netmask); + + if (rt-rt_ifp != NULL + rt-rt_ifp-if_type == IFT_PROPVIRTUAL) { + struct ifaddr *ifa; + + ifa = ifa_ifwithnet(info.rti_info[RTAX_DST], 1); + if (ifa != NULL) + rt_maskedcopy(ifa-ifa_addr, +
svn commit: r209277 - in stable/8/sys: net netinet
Author: qingli Date: Fri Jun 18 03:31:33 2010 New Revision: 209277 URL: http://svn.freebsd.org/changeset/base/209277 Log: MFC r208553 This patch fixes the problem where proxy ARP entries cannot be added over the if_ng interface. Modified: stable/8/sys/net/if.c stable/8/sys/net/if_var.h stable/8/sys/net/route.c stable/8/sys/net/rtsock.c stable/8/sys/netinet/in.c stable/8/sys/netinet/in_pcb.c stable/8/sys/netinet/ip_options.c stable/8/sys/netinet/ip_output.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/geom/sched/ (props changed) Modified: stable/8/sys/net/if.c == --- stable/8/sys/net/if.c Fri Jun 18 01:17:16 2010(r209276) +++ stable/8/sys/net/if.c Fri Jun 18 03:31:33 2010(r209277) @@ -1636,7 +1636,7 @@ done: * is most specific found. */ struct ifaddr * -ifa_ifwithnet(struct sockaddr *addr) +ifa_ifwithnet(struct sockaddr *addr, int ignore_ptp) { struct ifnet *ifp; struct ifaddr *ifa; @@ -1668,7 +1668,8 @@ ifa_ifwithnet(struct sockaddr *addr) if (ifa-ifa_addr-sa_family != af) next: continue; - if (af == AF_INET ifp-if_flags IFF_POINTOPOINT) { + if (af == AF_INET + ifp-if_flags IFF_POINTOPOINT !ignore_ptp) { /* * This is a bit broken as it doesn't * take into account that the remote end may Modified: stable/8/sys/net/if_var.h == --- stable/8/sys/net/if_var.h Fri Jun 18 01:17:16 2010(r209276) +++ stable/8/sys/net/if_var.h Fri Jun 18 03:31:33 2010(r209277) @@ -875,7 +875,7 @@ struct ifaddr *ifa_ifwithaddr(struct soc intifa_ifwithaddr_check(struct sockaddr *); struct ifaddr *ifa_ifwithbroadaddr(struct sockaddr *); struct ifaddr *ifa_ifwithdstaddr(struct sockaddr *); -struct ifaddr *ifa_ifwithnet(struct sockaddr *); +struct ifaddr *ifa_ifwithnet(struct sockaddr *, int); struct ifaddr *ifa_ifwithroute(int, struct sockaddr *, struct sockaddr *); struct ifaddr *ifa_ifwithroute_fib(int, struct sockaddr *, struct sockaddr *, u_int); Modified: stable/8/sys/net/route.c == --- stable/8/sys/net/route.cFri Jun 18 01:17:16 2010(r209276) +++ stable/8/sys/net/route.cFri Jun 18 03:31:33 2010(r209277) @@ -519,7 +519,7 @@ rtredirect_fib(struct sockaddr *dst, } /* verify the gateway is directly reachable */ - if ((ifa = ifa_ifwithnet(gateway)) == NULL) { + if ((ifa = ifa_ifwithnet(gateway, 0)) == NULL) { error = ENETUNREACH; goto out; } @@ -686,7 +686,7 @@ ifa_ifwithroute_fib(int flags, struct so ifa = ifa_ifwithdstaddr(gateway); } if (ifa == NULL) - ifa = ifa_ifwithnet(gateway); + ifa = ifa_ifwithnet(gateway, 0); if (ifa == NULL) { struct rtentry *rt = rtalloc1_fib(gateway, 0, RTF_RNH_LOCKED, fibnum); if (rt == NULL) @@ -797,7 +797,7 @@ rt_getifa_fib(struct rt_addrinfo *info, */ if (info-rti_ifp == NULL ifpaddr != NULL ifpaddr-sa_family == AF_LINK - (ifa = ifa_ifwithnet(ifpaddr)) != NULL) { + (ifa = ifa_ifwithnet(ifpaddr, 0)) != NULL) { info-rti_ifp = ifa-ifa_ifp; ifa_free(ifa); } Modified: stable/8/sys/net/rtsock.c == --- stable/8/sys/net/rtsock.c Fri Jun 18 01:17:16 2010(r209276) +++ stable/8/sys/net/rtsock.c Fri Jun 18 03:31:33 2010(r209277) @@ -55,6 +55,7 @@ #include net/if.h #include net/if_dl.h #include net/if_llatbl.h +#include net/if_types.h #include net/netisr.h #include net/raw_cb.h #include net/route.h @@ -673,12 +674,22 @@ route_output(struct mbuf *m, struct sock * another search to retrieve the prefix route of * the local end point of the PPP link. */ - if ((rtm-rtm_flags RTF_ANNOUNCE) - (rt-rt_ifp-if_flags IFF_POINTOPOINT)) { + if (rtm-rtm_flags RTF_ANNOUNCE) { struct sockaddr laddr; - rt_maskedcopy(rt-rt_ifa-ifa_addr, - laddr, - rt-rt_ifa-ifa_netmask); + +
svn commit: r209524 - in releng/8.1/sys: net netinet
Author: qingli Date: Fri Jun 25 21:26:34 2010 New Revision: 209524 URL: http://svn.freebsd.org/changeset/base/209524 Log: MFC r208553 This patch fixes the problem where proxy ARP entries cannot be added over the if_ng interface. Approved by: re (bz) Modified: releng/8.1/sys/net/if.c releng/8.1/sys/net/if_var.h releng/8.1/sys/net/route.c releng/8.1/sys/net/rtsock.c releng/8.1/sys/netinet/in.c releng/8.1/sys/netinet/in_pcb.c releng/8.1/sys/netinet/ip_options.c releng/8.1/sys/netinet/ip_output.c Directory Properties: releng/8.1/sys/ (props changed) releng/8.1/sys/amd64/include/xen/ (props changed) releng/8.1/sys/cddl/contrib/opensolaris/ (props changed) releng/8.1/sys/contrib/dev/acpica/ (props changed) releng/8.1/sys/contrib/pf/ (props changed) releng/8.1/sys/dev/ixgbe/ (props changed) releng/8.1/sys/dev/xen/xenpci/ (props changed) releng/8.1/sys/geom/sched/ (props changed) Modified: releng/8.1/sys/net/if.c == --- releng/8.1/sys/net/if.c Fri Jun 25 15:32:46 2010(r209523) +++ releng/8.1/sys/net/if.c Fri Jun 25 21:26:34 2010(r209524) @@ -1636,7 +1636,7 @@ done: * is most specific found. */ struct ifaddr * -ifa_ifwithnet(struct sockaddr *addr) +ifa_ifwithnet(struct sockaddr *addr, int ignore_ptp) { struct ifnet *ifp; struct ifaddr *ifa; @@ -1668,7 +1668,8 @@ ifa_ifwithnet(struct sockaddr *addr) if (ifa-ifa_addr-sa_family != af) next: continue; - if (af == AF_INET ifp-if_flags IFF_POINTOPOINT) { + if (af == AF_INET + ifp-if_flags IFF_POINTOPOINT !ignore_ptp) { /* * This is a bit broken as it doesn't * take into account that the remote end may Modified: releng/8.1/sys/net/if_var.h == --- releng/8.1/sys/net/if_var.h Fri Jun 25 15:32:46 2010(r209523) +++ releng/8.1/sys/net/if_var.h Fri Jun 25 21:26:34 2010(r209524) @@ -875,7 +875,7 @@ struct ifaddr *ifa_ifwithaddr(struct soc intifa_ifwithaddr_check(struct sockaddr *); struct ifaddr *ifa_ifwithbroadaddr(struct sockaddr *); struct ifaddr *ifa_ifwithdstaddr(struct sockaddr *); -struct ifaddr *ifa_ifwithnet(struct sockaddr *); +struct ifaddr *ifa_ifwithnet(struct sockaddr *, int); struct ifaddr *ifa_ifwithroute(int, struct sockaddr *, struct sockaddr *); struct ifaddr *ifa_ifwithroute_fib(int, struct sockaddr *, struct sockaddr *, u_int); Modified: releng/8.1/sys/net/route.c == --- releng/8.1/sys/net/route.c Fri Jun 25 15:32:46 2010(r209523) +++ releng/8.1/sys/net/route.c Fri Jun 25 21:26:34 2010(r209524) @@ -519,7 +519,7 @@ rtredirect_fib(struct sockaddr *dst, } /* verify the gateway is directly reachable */ - if ((ifa = ifa_ifwithnet(gateway)) == NULL) { + if ((ifa = ifa_ifwithnet(gateway, 0)) == NULL) { error = ENETUNREACH; goto out; } @@ -686,7 +686,7 @@ ifa_ifwithroute_fib(int flags, struct so ifa = ifa_ifwithdstaddr(gateway); } if (ifa == NULL) - ifa = ifa_ifwithnet(gateway); + ifa = ifa_ifwithnet(gateway, 0); if (ifa == NULL) { struct rtentry *rt = rtalloc1_fib(gateway, 0, RTF_RNH_LOCKED, fibnum); if (rt == NULL) @@ -797,7 +797,7 @@ rt_getifa_fib(struct rt_addrinfo *info, */ if (info-rti_ifp == NULL ifpaddr != NULL ifpaddr-sa_family == AF_LINK - (ifa = ifa_ifwithnet(ifpaddr)) != NULL) { + (ifa = ifa_ifwithnet(ifpaddr, 0)) != NULL) { info-rti_ifp = ifa-ifa_ifp; ifa_free(ifa); } Modified: releng/8.1/sys/net/rtsock.c == --- releng/8.1/sys/net/rtsock.c Fri Jun 25 15:32:46 2010(r209523) +++ releng/8.1/sys/net/rtsock.c Fri Jun 25 21:26:34 2010(r209524) @@ -55,6 +55,7 @@ #include net/if.h #include net/if_dl.h #include net/if_llatbl.h +#include net/if_types.h #include net/netisr.h #include net/raw_cb.h #include net/route.h @@ -673,12 +674,22 @@ route_output(struct mbuf *m, struct sock * another search to retrieve the prefix route of * the local end point of the PPP link. */ - if ((rtm-rtm_flags RTF_ANNOUNCE) - (rt-rt_ifp-if_flags IFF_POINTOPOINT)) { + if (rtm-rtm_flags RTF_ANNOUNCE) { struct sockaddr laddr; - rt_maskedcopy(rt-rt_ifa-ifa_addr, -
svn commit: r202132 - stable/8/sys/netinet
Author: qingli Date: Tue Jan 12 00:04:13 2010 New Revision: 202132 URL: http://svn.freebsd.org/changeset/base/202132 Log: MFC r201544 An existing incomplete ARP entry would expire a subsequent statically configured entry of the same host. This bug was due to the expiration timer was not cancelled when installing the static entry. Since there exist a potential race condition with respect to timer cancellation, simply check for the LLE_STATIC bit inside the expiration function instead of cancelling the active timer. Modified: stable/8/sys/netinet/if_ether.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/netinet/if_ether.c == --- stable/8/sys/netinet/if_ether.c Mon Jan 11 23:33:30 2010 (r202131) +++ stable/8/sys/netinet/if_ether.c Tue Jan 12 00:04:13 2010 (r202132) @@ -168,17 +168,23 @@ arptimer(void *arg) ifp = lle-lle_tbl-llt_ifp; IF_AFDATA_LOCK(ifp); LLE_WLOCK(lle); - if ((!callout_pending(lle-la_timer) - callout_active(lle-la_timer))) { - (void) llentry_free(lle); - } -#ifdef DIAGNOSTIC + if (lle-la_flags LLE_STATIC) + LLE_WUNLOCK(lle); else { - struct sockaddr *l3addr = L3_ADDR(lle); - log(LOG_INFO, arptimer issue: %p, IPv4 address: \%s\\n, lle, - inet_ntoa(((const struct sockaddr_in *)l3addr)-sin_addr)); - } + if (!callout_pending(lle-la_timer) + callout_active(lle-la_timer)) { + (void) llentry_free(lle); + } +#ifdef DIAGNOSTIC + else { + struct sockaddr *l3addr = L3_ADDR(lle); + log(LOG_INFO, + arptimer issue: %p, IPv4 address: \%s\\n, lle, + inet_ntoa( + ((const struct sockaddr_in *)l3addr)-sin_addr)); + } #endif + } IF_AFDATA_UNLOCK(ifp); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r203401 - head/sys/netinet
Author: qingli Date: Tue Feb 2 20:38:30 2010 New Revision: 203401 URL: http://svn.freebsd.org/changeset/base/203401 Log: Some of the existing ppp and vpn related scripts create and set the IP addresses of the tunnel end points to the same value. In these cases the loopback route is not installed for the local end. Verified by: avg MFC after:5 days Modified: head/sys/netinet/in.c Modified: head/sys/netinet/in.c == --- head/sys/netinet/in.c Tue Feb 2 20:37:11 2010(r203400) +++ head/sys/netinet/in.c Tue Feb 2 20:38:30 2010(r203401) @@ -921,6 +921,12 @@ in_ifinit(struct ifnet *ifp, struct in_i if (ia-ia_addr.sin_addr.s_addr == INADDR_ANY) return (0); + if (ifp-if_flags IFF_POINTOPOINT) { + if (ia-ia_dstaddr.sin_addr.s_addr == ia-ia_addr.sin_addr.s_addr) + return (0); + } + + /* * add a loopback route to self */ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r203718 - stable/8/sys/netinet
Author: qingli Date: Tue Feb 9 19:27:54 2010 New Revision: 203718 URL: http://svn.freebsd.org/changeset/base/203718 Log: MFC r203401 Some of the existing ppp and vpn related scripts create and set the IP addresses of the tunnel end points to the same value. In these cases the loopback route is not installed for the local end. Modified: stable/8/sys/netinet/in.c Directory Properties: stable/8/sys/netinet/ (props changed) Modified: stable/8/sys/netinet/in.c == --- stable/8/sys/netinet/in.c Tue Feb 9 19:13:45 2010(r203717) +++ stable/8/sys/netinet/in.c Tue Feb 9 19:27:54 2010(r203718) @@ -921,6 +921,12 @@ in_ifinit(struct ifnet *ifp, struct in_i if (ia-ia_addr.sin_addr.s_addr == INADDR_ANY) return (0); + if (ifp-if_flags IFF_POINTOPOINT) { + if (ia-ia_dstaddr.sin_addr.s_addr == ia-ia_addr.sin_addr.s_addr) + return (0); + } + + /* * add a loopback route to self */ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r192282 - head/sys/netinet6
Author: qingli Date: Mon May 18 02:25:45 2009 New Revision: 192282 URL: http://svn.freebsd.org/changeset/base/192282 Log: This patch resolves the following issues: -- A routing socket message is not generated when an IPv6 address is either inserted or deleted from an interface. The missing routing message problem was discovered by Randall Stewart and Michael Tuxen during SCTP testing. -- Previously when an IPv6 address is configured on an interface, if the prefix length is /128, then a host route is instaleld in the kernel for this address. But this host route is not deleted when that IPv6 address is removed from the interface. -- Routes to the link-local all-nodes multicast address and the interface-local all-nodes multicast address are not removed when the last IPv6 address is removed from an interface. Reviewed by: bz, gnn Modified: head/sys/netinet6/in6.c Modified: head/sys/netinet6/in6.c == --- head/sys/netinet6/in6.c Mon May 18 01:51:52 2009(r192281) +++ head/sys/netinet6/in6.c Mon May 18 02:25:45 2009(r192282) @@ -1151,6 +1151,28 @@ in6_purgeaddr(struct ifaddr *ifa) struct ifnet *ifp = ifa-ifa_ifp; struct in6_ifaddr *ia = (struct in6_ifaddr *) ifa; struct in6_multi_mship *imm; + struct sockaddr_in6 mltaddr, mltmask; + struct rtentry rt0; + struct sockaddr_dl gateway; + struct sockaddr_in6 mask, addr; + int plen, error; + struct rtentry *rt; + struct ifaddr *ifa0, *nifa; + + /* +* find another IPv6 address as the gateway for the +* link-local and node-local all-nodes multicast +* address routes +*/ + TAILQ_FOREACH_SAFE(ifa0, ifp-if_addrhead, ifa_link, nifa) { + if ((ifa0-ifa_addr-sa_family != AF_INET6) || + memcmp(satosin6(ifa0-ifa_addr)-sin6_addr, + ia-ia_addr.sin6_addr, + sizeof(struct in6_addr)) == 0) + continue; + else + break; + } /* stop DAD processing */ nd6_dad_stop(ifa); @@ -1159,7 +1181,25 @@ in6_purgeaddr(struct ifaddr *ifa) lla_lookup(LLTABLE6(ifp), (LLE_DELETE | LLE_IFADDR), (struct sockaddr *)ia-ia_addr); IF_AFDATA_UNLOCK(ifp); - + + /* +* initialize for rtmsg generation +*/ + bzero(gateway, sizeof(gateway)); + gateway.sdl_len = sizeof(gateway); + gateway.sdl_family = AF_LINK; + gateway.sdl_nlen = 0; + gateway.sdl_alen = ifp-if_addrlen; + /* */ + bzero(rt0, sizeof(rt0)); + rt0.rt_gateway = (struct sockaddr *)gateway; + memcpy(mask, ia-ia_prefixmask, sizeof(ia-ia_prefixmask)); + memcpy(addr, ia-ia_addr, sizeof(ia-ia_addr)); + rt_mask(rt0) = (struct sockaddr *)mask; + rt_key(rt0) = (struct sockaddr *)addr; + rt0.rt_flags = RTF_HOST | RTF_STATIC; + rt_newaddrmsg(RTM_DELETE, ifa, 0, rt0); + /* * leave from multicast groups we have joined for the interface */ @@ -1168,6 +1208,139 @@ in6_purgeaddr(struct ifaddr *ifa) in6_leavegroup(imm); } + /* +* remove the link-local all-nodes address +*/ + bzero(mltmask, sizeof(mltmask)); + mltmask.sin6_len = sizeof(struct sockaddr_in6); + mltmask.sin6_family = AF_INET6; + mltmask.sin6_addr = in6mask32; + + bzero(mltaddr, sizeof(mltaddr)); + mltaddr.sin6_len = sizeof(struct sockaddr_in6); + mltaddr.sin6_family = AF_INET6; + mltaddr.sin6_addr = in6addr_linklocal_allnodes; + + if ((error = in6_setscope(mltaddr.sin6_addr, ifp, NULL)) != + 0) + goto cleanup; + + rt = rtalloc1((struct sockaddr *)mltaddr, 0, 0UL); + if (rt != NULL rt-rt_gateway != NULL + (memcmp(satosin6(rt-rt_gateway)-sin6_addr, + ia-ia_addr.sin6_addr, + sizeof(ia-ia_addr.sin6_addr)) == 0)) { + /* +* if no more IPv6 address exists on this interface +* then remove the multicast address route +*/ + if (ifa0 == NULL) { + memcpy(mltaddr.sin6_addr, satosin6(rt_key(rt))-sin6_addr, + sizeof(mltaddr.sin6_addr)); + RTFREE_LOCKED(rt); + error = rtrequest(RTM_DELETE, (struct sockaddr *)mltaddr, + (struct sockaddr *)ia-ia_addr, + (struct sockaddr *)mltmask, RTF_UP, + (struct rtentry **)0); + if (error) + log(LOG_INFO, in6_purgeaddr: link-local all-nodes +
svn commit: r192476 - in head/sys: net netinet netinet6
Author: qingli Date: Wed May 20 21:07:15 2009 New Revision: 192476 URL: http://svn.freebsd.org/changeset/base/192476 Log: When an interface address is removed and the last prefix route is also being deleted, the link-layer address table (arp or nd6) will flush those L2 llinfo entries that match the removed prefix. Reviewed by: kmacy Modified: head/sys/net/if_llatbl.c head/sys/net/if_llatbl.h head/sys/netinet/in.c head/sys/netinet6/in6.c Modified: head/sys/net/if_llatbl.c == --- head/sys/net/if_llatbl.cWed May 20 21:04:41 2009(r192475) +++ head/sys/net/if_llatbl.cWed May 20 21:07:15 2009(r192476) @@ -195,6 +195,23 @@ lltable_drain(int af) IFNET_RUNLOCK(); } +void +lltable_prefix_free(int af, struct sockaddr *prefix, struct sockaddr *mask) +{ + struct lltable *llt; + + IFNET_RLOCK(); + SLIST_FOREACH(llt, lltables, llt_link) { + if (llt-llt_af != af) + continue; + + llt-llt_prefix_free(llt, prefix, mask); + } + IFNET_RUNLOCK(); +} + + + /* * Create a new lltable. */ Modified: head/sys/net/if_llatbl.h == --- head/sys/net/if_llatbl.hWed May 20 21:04:41 2009(r192475) +++ head/sys/net/if_llatbl.hWed May 20 21:07:15 2009(r192476) @@ -147,6 +147,9 @@ struct lltable { struct llentry *(*llt_new)(const struct sockaddr *, u_int); void(*llt_free)(struct lltable *, struct llentry *); + void(*llt_prefix_free)(struct lltable *, + const struct sockaddr *prefix, + const struct sockaddr *mask); struct llentry *(*llt_lookup)(struct lltable *, u_int flags, const struct sockaddr *l3addr); int (*llt_rtcheck)(struct ifnet *, @@ -174,6 +177,8 @@ MALLOC_DECLARE(M_LLTABLE); struct lltable *lltable_init(struct ifnet *, int); void lltable_free(struct lltable *); +void lltable_prefix_free(int, struct sockaddr *, + struct sockaddr *); void lltable_drain(int); intlltable_sysctl_dumparp(int, struct sysctl_req *); Modified: head/sys/netinet/in.c == --- head/sys/netinet/in.c Wed May 20 21:04:41 2009(r192475) +++ head/sys/netinet/in.c Wed May 20 21:07:15 2009(r192476) @@ -1013,6 +1013,7 @@ in_scrubprefix(struct in_ifaddr *target) struct in_ifaddr *ia; struct in_addr prefix, mask, p; int error; + struct sockaddr_in prefix0, mask0; struct rt_addrinfo info; struct sockaddr_dl null_sdl; @@ -1082,6 +1083,20 @@ in_scrubprefix(struct in_ifaddr *target) } /* +* remove all L2 entries on the given prefix +*/ + bzero(prefix0, sizeof(prefix0)); + prefix0.sin_len = sizeof(prefix0); + prefix0.sin_family = AF_INET; + prefix0.sin_addr.s_addr = target-ia_subnet; + bzero(mask0, sizeof(mask0)); + mask0.sin_len = sizeof(mask0); + mask0.sin_family = AF_INET; + mask0.sin_addr.s_addr = target-ia_subnetmask; + lltable_prefix_free(AF_INET, (struct sockaddr *)prefix0, + (struct sockaddr *)mask0); + + /* * As no-one seem to have this prefix, we can remove the route. */ rtinit((target-ia_ifa), (int)RTM_DELETE, rtinitflags(target)); @@ -1232,6 +1247,34 @@ in_lltable_free(struct lltable *llt, str free(lle, M_LLTABLE); } + +#define IN_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \ + (((ntohl((d)-sin_addr.s_addr) ^ (a)-sin_addr.s_addr) (m)-sin_addr.s_addr)) == 0 ) + +static void +in_lltable_prefix_free(struct lltable *llt, + const struct sockaddr *prefix, + const struct sockaddr *mask) +{ + const struct sockaddr_in *pfx = (const struct sockaddr_in *)prefix; + const struct sockaddr_in *msk = (const struct sockaddr_in *)mask; + struct llentry *lle, *next; + register int i; + + for (i=0; i LLTBL_HASHTBL_SIZE; i++) { + LIST_FOREACH_SAFE(lle, llt-lle_head[i], lle_next, next) { + + if (IN_ARE_MASKED_ADDR_EQUAL((struct sockaddr_in *)L3_ADDR(lle), +pfx, msk)) { + callout_drain(lle-la_timer); + LLE_WLOCK(lle); + llentry_free(lle); + } + } + } +} + + static int in_lltable_rtcheck(struct ifnet *ifp, const struct sockaddr *l3addr) { @@ -1422,6 +1465,7 @@
RE: svn commit: r191305 - head/usr.sbin/ppp
Are you really sure backing this change out is the right thing to do ?? -- Qing -Original Message- From: owner-src-committ...@freebsd.org [mailto:owner-src-committ...@freebsd.org] On Behalf Of Bjoern A. Zeeb Sent: Monday, April 20, 2009 4:23 AM To: src-committ...@freebsd.org; svn-src-all@freebsd.org; svn-src-h...@freebsd.org Subject: svn commit: r191305 - head/usr.sbin/ppp Author: bz Date: Mon Apr 20 11:22:51 2009 New Revision: 191305 URL: http://svn.freebsd.org/changeset/base/191305 Log: Back out r186308: in case of AF_LINK, which the kernel still returns for an RTAX_GATEWAY as an empty sockaddr_dl in the classic tunn case. Copying the address into the message payload, but not the RTA_GATEWAY flag results in rt_xaddrs() in the kernel tripping over that and parsing the next attribute set with a flag, i.e. RTA_NETMASK, with the gateway address, resulting in bogus route entry. MFC after: 3 days Modified: head/usr.sbin/ppp/route.c Modified: head/usr.sbin/ppp/route.c == --- head/usr.sbin/ppp/route.c Mon Apr 20 10:40:42 2009 (r191304) +++ head/usr.sbin/ppp/route.c Mon Apr 20 11:22:51 2009 (r191305) @@ -910,10 +910,8 @@ rt_Update(struct bundle *bundle, const s p += memcpy_roundup(p, dst, dst-sa_len); } - if (gw != NULL (gw-sa_family != AF_LINK)) -rtmes.m_rtm.rtm_addrs |= RTA_GATEWAY; + rtmes.m_rtm.rtm_addrs |= RTA_GATEWAY; p += memcpy_roundup(p, gw, gw-sa_len); - if (mask) { rtmes.m_rtm.rtm_addrs |= RTA_NETMASK; p += memcpy_roundup(p, mask, mask-sa_len); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r192011 - head/sys/netinet
Author: qingli Date: Tue May 12 07:41:20 2009 New Revision: 192011 URL: http://svn.freebsd.org/changeset/base/192011 Log: This patch adds a host route to an interface address (that is assigned to a non loopback/ppp link types) through the loopback interface. Prior to the new L2/L3 rewrite, this host route is implicitly added by the L2 code during RTM_RESOLVE of that interface address. This host route is deleted when that interface is removed. Reviewed by: kmacy Modified: head/sys/netinet/in.c Modified: head/sys/netinet/in.c == --- head/sys/netinet/in.c Tue May 12 05:49:02 2009(r192010) +++ head/sys/netinet/in.c Tue May 12 07:41:20 2009(r192011) @@ -45,12 +45,15 @@ __FBSDID($FreeBSD$); #include sys/kernel.h #include sys/proc.h #include sys/sysctl.h +#include sys/syslog.h #include sys/vimage.h #include net/if.h +#include net/if_dl.h #include net/if_llatbl.h #include net/if_types.h #include net/route.h +#include net/vnet.h #include netinet/in.h #include netinet/in_var.h @@ -814,6 +817,9 @@ in_ifinit(struct ifnet *ifp, struct in_i INIT_VNET_INET(ifp-if_vnet); register u_long i = ntohl(sin-sin_addr.s_addr); struct sockaddr_in oldaddr; + struct rtentry *rt = NULL; + struct rt_addrinfo info; + static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK}; int s = splimp(), flags = RTF_UP, error = 0; oldaddr = ia-ia_addr; @@ -900,6 +906,29 @@ in_ifinit(struct ifnet *ifp, struct in_i if ((error = in_addprefix(ia, flags)) != 0) return (error); + /* +* add a loopback route to self +*/ + if (!(ifp-if_flags (IFF_LOOPBACK | IFF_POINTOPOINT))) { + bzero(info, sizeof(info)); + info.rti_ifp = V_loif; + info.rti_flags = ia-ia_flags | RTF_HOST | RTF_STATIC; + info.rti_info[RTAX_DST] = (struct sockaddr *)ia-ia_addr; + info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)null_sdl; + error = rtrequest1_fib(RTM_ADD, info, rt, 0); + + if (error == 0 rt != NULL) { + RT_LOCK(rt); + ((struct sockaddr_dl *)rt-rt_gateway)-sdl_type = + rt-rt_ifp-if_type; + ((struct sockaddr_dl *)rt-rt_gateway)-sdl_index = + rt-rt_ifp-if_index; + RT_REMREF(rt); + RT_UNLOCK(rt); + } else if (error != 0) + log(LOG_INFO, in_ifinit: insertion failed\n); + } + return (error); } @@ -979,10 +1008,28 @@ in_scrubprefix(struct in_ifaddr *target) struct in_ifaddr *ia; struct in_addr prefix, mask, p; int error; + struct rt_addrinfo info; + struct sockaddr_dl null_sdl; if ((target-ia_flags IFA_ROUTE) == 0) return (0); + if (!(target-ia_ifp-if_flags (IFF_LOOPBACK | IFF_POINTOPOINT))) { + bzero(null_sdl, sizeof(null_sdl)); + null_sdl.sdl_len = sizeof(null_sdl); + null_sdl.sdl_family = AF_LINK; + null_sdl.sdl_type = V_loif-if_type; + null_sdl.sdl_index = V_loif-if_index; + bzero(info, sizeof(info)); + info.rti_flags = target-ia_flags | RTF_HOST | RTF_STATIC; + info.rti_info[RTAX_DST] = (struct sockaddr *)target-ia_addr; + info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)null_sdl; + error = rtrequest1_fib(RTM_DELETE, info, NULL, 0); + + if (error != 0) + log(LOG_INFO, in_scrubprefix: deletion failed\n); + } + if (rtinitflags(target)) prefix = target-ia_dstaddr.sin_addr; else { @@ -1136,7 +1183,6 @@ in_purgemaddrs(struct ifnet *ifp) IN_MULTI_UNLOCK(); } -#include sys/syslog.h #include net/if_dl.h #include netinet/if_ether.h ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r192085 - head/sys/netinet
Author: qingli Date: Thu May 14 05:27:09 2009 New Revision: 192085 URL: http://svn.freebsd.org/changeset/base/192085 Log: Ignore the INADDR_ANY address inserted/deleted by DHCP when installing a loopback route to the interface address. Modified: head/sys/netinet/in.c Modified: head/sys/netinet/in.c == --- head/sys/netinet/in.c Thu May 14 03:54:03 2009(r192084) +++ head/sys/netinet/in.c Thu May 14 05:27:09 2009(r192085) @@ -906,6 +906,9 @@ in_ifinit(struct ifnet *ifp, struct in_i if ((error = in_addprefix(ia, flags)) != 0) return (error); + if (ia-ia_addr.sin_addr.s_addr == INADDR_ANY) + return (0); + /* * add a loopback route to self */ @@ -1014,7 +1017,8 @@ in_scrubprefix(struct in_ifaddr *target) if ((target-ia_flags IFA_ROUTE) == 0) return (0); - if (!(target-ia_ifp-if_flags (IFF_LOOPBACK | IFF_POINTOPOINT))) { + if ((target-ia_addr.sin_addr.s_addr != INADDR_ANY) + !(target-ia_ifp-if_flags (IFF_LOOPBACK | IFF_POINTOPOINT))) { bzero(null_sdl, sizeof(null_sdl)); null_sdl.sdl_len = sizeof(null_sdl); null_sdl.sdl_family = AF_LINK; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
RE: svn commit: r192085 - head/sys/netinet
-Original Message- From: George Neville-Neil [mailto:g...@neville-neil.com] Sent: Thursday, May 14, 2009 7:36 AM To: Qing Li Cc: src-committ...@freebsd.org; svn-src-all@FreeBSD.org; svn-src-h...@freebsd.org Subject: Re: svn commit: r192085 - head/sys/netinet On May 13, 2009, at 22:27 , Qing Li wrote: Author: qingli Date: Thu May 14 05:27:09 2009 New Revision: 192085 URL: http://svn.freebsd.org/changeset/base/192085 Log: Ignore the INADDR_ANY address inserted/deleted by DHCP when installing a loopback route to the interface address. Can you give more detail as to the purpose of this change? I'm a bit confused by it. Does this fix any of the recent problems seen with DHCP and PXE or is this unrelated? The DHCP client code adds a 0.0.0.0 address and then deletes it once the server assign the node a real IP. It's easily Observed by running dhclient followed by netstat. I had to take care of this DHCP related bits before, e.g., not creating an ARP entry for it. That's really it. Exactly which part is confusing you ? -- Qing ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r204402 - head/sys/netinet6
Author: qingli Date: Sat Feb 27 07:12:25 2010 New Revision: 204402 URL: http://svn.freebsd.org/changeset/base/204402 Log: Use reference counting instead of locking to secure an address while that address is being used to generate temporary IPv6 address. This approach is sufficient and avoids recursive locking. MFC after:3 days Modified: head/sys/netinet6/nd6.c Modified: head/sys/netinet6/nd6.c == --- head/sys/netinet6/nd6.c Sat Feb 27 06:28:22 2010(r204401) +++ head/sys/netinet6/nd6.c Sat Feb 27 07:12:25 2010(r204402) @@ -764,22 +764,25 @@ regen_tmpaddr(struct in6_ifaddr *ia6) */ if (!IFA6_IS_DEPRECATED(it6)) public_ifa6 = it6; + + if (public_ifa6 != NULL) + ifa_ref(public_ifa6-ia_ifa); } + IF_ADDR_UNLOCK(ifp); if (public_ifa6 != NULL) { int e; if ((e = in6_tmpifadd(public_ifa6, 0, 0)) != 0) { - IF_ADDR_UNLOCK(ifp); + ifa_free(public_ifa6-ia_ifa); log(LOG_NOTICE, regen_tmpaddr: failed to create a new tmp addr,errno=%d\n, e); return (-1); } - IF_ADDR_UNLOCK(ifp); + ifa_free(public_ifa6-ia_ifa); return (0); } - IF_ADDR_UNLOCK(ifp); return (-1); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r204893 - stable/8/sys/netinet6
Author: qingli Date: Mon Mar 8 21:30:12 2010 New Revision: 204893 URL: http://svn.freebsd.org/changeset/base/204893 Log: MFC 204402 Use reference counting instead of locking to secure an address while that address is being used to generate temporary IPv6 address. This approach is sufficient and avoids recursive locking. Modified: stable/8/sys/netinet6/nd6.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet/ (props changed) Modified: stable/8/sys/netinet6/nd6.c == --- stable/8/sys/netinet6/nd6.c Mon Mar 8 21:29:09 2010(r204892) +++ stable/8/sys/netinet6/nd6.c Mon Mar 8 21:30:12 2010(r204893) @@ -759,22 +759,25 @@ regen_tmpaddr(struct in6_ifaddr *ia6) */ if (!IFA6_IS_DEPRECATED(it6)) public_ifa6 = it6; + + if (public_ifa6 != NULL) + ifa_ref(public_ifa6-ia_ifa); } + IF_ADDR_UNLOCK(ifp); if (public_ifa6 != NULL) { int e; if ((e = in6_tmpifadd(public_ifa6, 0, 0)) != 0) { - IF_ADDR_UNLOCK(ifp); + ifa_free(public_ifa6-ia_ifa); log(LOG_NOTICE, regen_tmpaddr: failed to create a new tmp addr,errno=%d\n, e); return (-1); } - IF_ADDR_UNLOCK(ifp); + ifa_free(public_ifa6-ia_ifa); return (0); } - IF_ADDR_UNLOCK(ifp); return (-1); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r204902 - in head/sys: net netinet
Author: qingli Date: Tue Mar 9 01:11:45 2010 New Revision: 204902 URL: http://svn.freebsd.org/changeset/base/204902 Log: One of the advantages of enabling ECMP (a.k.a RADIX_MPATH) is to allow for connection load balancing across interfaces. Currently the address alias handling method is colliding with the ECMP code. For example, when two interfaces are configured on the same prefix, only one prefix route is installed. So connection load balancing among the available interfaces is not possible. The other advantage of ECMP is for failover. The issue with the current code, is that the interface link-state is not reflected in the route entry. For example, if there are two interfaces on the same prefix, the cable on one interface is unplugged, new and existing connections should switch over to the other interface. This is not done today and packets go into a black hole. Also, there is a small bug in the kernel where deleting ECMP routes in the userland will always return an error even though the command is successfully executed. MFC after:5 days Modified: head/sys/net/flowtable.c head/sys/net/radix.c head/sys/net/radix_mpath.c head/sys/net/route.c head/sys/net/route.h head/sys/netinet/in.c head/sys/netinet/ip_output.c Modified: head/sys/net/flowtable.c == --- head/sys/net/flowtable.cTue Mar 9 00:52:16 2010(r204901) +++ head/sys/net/flowtable.cTue Mar 9 01:11:45 2010(r204902) @@ -472,7 +472,8 @@ flow_stale(struct flowtable *ft, struct || ((fle-f_rt-rt_flags RTF_HOST) ((fle-f_rt-rt_flags (RTF_UP)) != (RTF_UP))) - || (fle-f_rt-rt_ifp == NULL)) + || (fle-f_rt-rt_ifp == NULL) + || !RT_LINK_IS_UP(fle-f_rt-rt_ifp)) return (1); idle_time = time_uptime - fle-f_uptime; Modified: head/sys/net/radix.c == --- head/sys/net/radix.cTue Mar 9 00:52:16 2010(r204901) +++ head/sys/net/radix.cTue Mar 9 01:11:45 2010(r204902) @@ -761,8 +761,10 @@ on2: if (m-rm_flags RNF_NORMAL) { mmask = m-rm_leaf-rn_mask; if (tt-rn_flags RNF_NORMAL) { +#if !defined(RADIX_MPATH) log(LOG_ERR, Non-unique normal route, mask not entered\n); +#endif return tt; } } else Modified: head/sys/net/radix_mpath.c == --- head/sys/net/radix_mpath.c Tue Mar 9 00:52:16 2010(r204901) +++ head/sys/net/radix_mpath.c Tue Mar 9 01:11:45 2010(r204902) @@ -270,7 +270,8 @@ rtalloc_mpath_fib(struct route *ro, uint * XXX we don't attempt to lookup cached route again; what should * be done for sendto(3) case? */ - if (ro-ro_rt ro-ro_rt-rt_ifp (ro-ro_rt-rt_flags RTF_UP)) + if (ro-ro_rt ro-ro_rt-rt_ifp (ro-ro_rt-rt_flags RTF_UP) +RT_LINK_IS_UP(ro-ro_rt-rt_ifp)) return; ro-ro_rt = rtalloc1_fib(ro-ro_dst, 1, 0, fibnum); Modified: head/sys/net/route.c == --- head/sys/net/route.cTue Mar 9 00:52:16 2010(r204901) +++ head/sys/net/route.cTue Mar 9 01:11:45 2010(r204902) @@ -830,7 +830,13 @@ rt_getifa_fib(struct rt_addrinfo *info, int rtexpunge(struct rtentry *rt) { +#if !defined(RADIX_MPATH) struct radix_node *rn; +#else + struct rt_addrinfo info; + int fib; + struct rtentry *rt0; +#endif struct radix_node_head *rnh; struct ifaddr *ifa; int error = 0; @@ -843,14 +849,26 @@ rtexpunge(struct rtentry *rt) if (rnh == NULL) return (EAFNOSUPPORT); RADIX_NODE_HEAD_LOCK_ASSERT(rnh); -#if 0 - /* -* We cannot assume anything about the reference count -* because protocols call us in many situations; often -* before unwinding references to the table entry. -*/ - KASSERT(rt-rt_refcnt = 1, (bogus refcnt %ld, rt-rt_refcnt)); -#endif + +#ifdef RADIX_MPATH + fib = rt-rt_fibnum; + bzero(info, sizeof(info)); + info.rti_ifp = rt-rt_ifp; + info.rti_flags = RTF_RNH_LOCKED; + info.rti_info[RTAX_DST] = rt_key(rt); + info.rti_info[RTAX_GATEWAY] = rt-rt_ifa-ifa_addr; + + RT_UNLOCK(rt); + error = rtrequest1_fib(RTM_DELETE, info, rt0, fib); + + if (error == 0 rt0 != NULL) { + rt = rt0; + RT_LOCK(rt); + } else if (error != 0) { + RT_LOCK(rt); + return (error); + } +#else /*
Re: svn commit: r204902 - in head/sys: net netinet
I looked at it, and at the diff of his original commit. Â The changes were large enough that I don't want to assume his patch takes care of all the issues given that patch hasn't been committed verbatim. The change itself is not a huge change but if you disagree, then please be specific. The current mechanism and code is broken according to the original design intention. I have a habit of not committing things or quick finger until everyone had a chance to test the patch, although I have done unit testings myself. When you say ... made the kernel toxic and ...I don't want to assume ..., well, again, be specific instead about what you mean and give me details. The other reason I decided to postpone is because I wanted to spend more time with the PPP driver. Every other PPP interface types (if_tun, if_ng etc.) updates the if_link_state variable except PPP. We also have reports of the patch not working in freebsd-curr...@. I have seen that report but it lacks detail. I have asked for more information and will investigate further as soon as it becomes available. -- Qing ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r205024 - head/sys/net
Author: qingli Date: Thu Mar 11 17:56:46 2010 New Revision: 205024 URL: http://svn.freebsd.org/changeset/base/205024 Log: The if_tap interface is of IFT_ETHERNET type, but it does not set or update the if_link_state variable. As such RT_LINK_IS_UP() fails for the if_tap interface. Also, the RT_LINK_IS_UP() needs to bypass all loopback interfaces because loopback interfaces are considered up logically as long as the system is running. This patch fixes the above issues by setting and updating the if_link_state variable when the tap interface is opened or closed respectively. Similary approach is already done in the if_tun device. MFC after:3 days Modified: head/sys/net/if_tap.c head/sys/net/route.h Modified: head/sys/net/if_tap.c == --- head/sys/net/if_tap.c Thu Mar 11 17:15:40 2010(r205023) +++ head/sys/net/if_tap.c Thu Mar 11 17:56:46 2010(r205024) @@ -502,6 +502,7 @@ tapopen(struct cdev *dev, int flag, int ifp-if_drv_flags = ~IFF_DRV_OACTIVE; if (tapuponopen) ifp-if_flags |= IFF_UP; + if_link_state_change(ifp, LINK_STATE_UP); splx(s); TAPDEBUG(%s is open. minor = %#x\n, ifp-if_xname, dev2unit(dev)); @@ -547,6 +548,7 @@ tapclose(struct cdev *dev, int foo, int } else mtx_unlock(tp-tap_mtx); + if_link_state_change(ifp, LINK_STATE_DOWN); funsetown(tp-tap_sigio); selwakeuppri(tp-tap_rsel, PZERO+1); KNOTE_UNLOCKED(tp-tap_rsel.si_note, 0); Modified: head/sys/net/route.h == --- head/sys/net/route.hThu Mar 11 17:15:40 2010(r205023) +++ head/sys/net/route.hThu Mar 11 17:56:46 2010(r205024) @@ -319,7 +319,9 @@ struct rt_addrinfo { #ifdef _KERNEL -#define RT_LINK_IS_UP(ifp) ((ifp)-if_link_state == LINK_STATE_UP) +#define RT_LINK_IS_UP(ifp) (((ifp)-if_flags \ + (IFF_LOOPBACK | IFF_POINTOPOINT)) \ +|| (ifp)-if_link_state == LINK_STATE_UP) #defineRT_LOCK_INIT(_rt) \ mtx_init((_rt)-rt_mtx, rtentry, NULL, MTX_DEF | MTX_DUPOK) ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r205024 - head/sys/net
A couple of questions: (1) It used to be the case that quite a few interface drivers and types didn't have a notion of link up -- especially older ethernet devices.  Do those all have the same problem?  It was probably a design oversight that  devices don't declare an explicit capability for can report link state. What you raised is definitely a possibility and these fixes take the similar approach. I am going to try and go through each of these drivers in /sys/dev/ and converting them, very soon. (2) While loopback interfaces don't really have a link state, they can be  administratively down -- should/do you check that as well as link state? And more generally, even if link is up, administratively down should be  obeyed? For loopback interfaces, althgouth administrative these can be taken down, I personally cannot think one practical usage case where ECMP across loopback interfaces would be interesting or usefaul. So I can think of very little reason to be concerned in the loopback case. Finally, it would be neat if there were a way to have information beyond link state influence the choice to balance to a particular route/interface.  For example, imagine if I have a router with ECMP, and on the other side on a single ethernet segment, I have two DSL modems.  The ethernet link will remain up, but I may (via out-of-band mechanisms, such as SNMP or an active probe) be able to tell that one of the DSL lines is down.  Is there a way to push that information into the kernel currently without deleting the routes, and instead say yeah, but for ECMP purposes this is 'down'? The above really falls into policy based routing. And policy based routing infrastrucutre is something I have already been working on but cannot yet push back into -current. In fact Julian and I had a conversation about this topic during the FIBs implementation time in late 2008. This infrastructure enhancement is definitely coming but I cannot yet prvoide a timeline for merge back. It's mostly a time issue. Let me know if I have answered these questions to your satisfaction. -- Qing ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r205024 - head/sys/net
I guess it's a good time to clean things up. The if_link_state code has been around for quite some time, either it be fully utilized or not be there at all. The inconsistency is the root cause. I will try going through these tonight and hopefully the fix all take a common approach. -- Qing On Thu, Mar 11, 2010 at 3:35 PM, Juli Mallett jmall...@freebsd.org wrote: On Thu, Mar 11, 2010 at 15:30, Qing Li qin...@freebsd.org wrote: A couple of questions: (1) It used to be the case that quite a few interface drivers and types didn't have a notion of link up -- especially older ethernet devices.  Do those all have the same problem?  It was probably a design oversight that  devices don't declare an explicit capability for can report link state.  What you raised is definitely a possibility and these fixes take the  similar approach. I am going to try and go through each of these  drivers in /sys/dev/ and converting them, very soon. Go through drivers in the embedded port directories, too.  The Octeon port's Ethernet driver was broken by this, and it looks like the Atheros if_arge is probably broken, too.  I would even suggest going back to the old behavior briefly while the port maintainers are given an opportunity to update their drivers.  Actually, it looks like only MIPS has Ethernet drivers outside of dev/ at a quick glance, but I'd be surprised if there weren't other broken examples. Juli. ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r205024 - head/sys/net
If you can think of a way to add some invariants (warn the first time a driver receives a packet without having ever set the link state, make sure the media status callback sets the valid flag in the request, etc) that would probably be very helpful for people who are writing network drivers. Â If I hadn't been following the threads about your changes, I would have had to spend much longer fixing the Octeon port's Ethernet driver, wondering why suddenly it broke and instrumenting the routing code. Â A printf would go a long way. You definitely have a very good point here. I was a bit surprised during debugging that the link state is not consistently initialized and by far not enforced across all of the drivers. Admittedly I checked the most commonly deployed devices and they are in good state. I certainly appreciate your patience on this one and will try to get it resolved quickly. -- Qing ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r205024 - head/sys/net
That's a good idea. I will take your approach. -- Qing On Thu, Mar 11, 2010 at 11:15 PM, Julian Elischer jul...@elischer.org wrote: Juli Mallett wrote: On Thu, Mar 11, 2010 at 15:39, Qing Li qin...@freebsd.org wrote: I guess it's a good time to clean things up. The if_link_state code has been around for quite some time, either it be fully utilized or not be there at all. The inconsistency is the root cause. Sure. Â There is an increasing amount of stuff that network drivers are expected to do, but they work without doing them. Â It's easy to think you have a functioning network driver and that you can get by without adding support for media changes and link status reporting, etc. I will try going through these tonight and hopefully the fix all take a common approach. probably should add a flag that means we have media state and if it is not set, assume it is always on. If you can think of a way to add some invariants (warn the first time a driver receives a packet without having ever set the link state, make sure the media status callback sets the valid flag in the request, etc) that would probably be very helpful for people who are writing network drivers. Â If I hadn't been following the threads about your changes, I would have had to spend much longer fixing the Octeon port's Ethernet driver, wondering why suddenly it broke and instrumenting the routing code. Â A printf would go a long way. Juli. ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r205024 - head/sys/net
Is there any way we can pick up via an assertion that an interface driver has failed to implement this functionality? This has never been a historic requirement, so I suspect there are a lot of drivers floating around that fail to meet the requirement. Also, is this for IFT_ETHER only, or also other link types? Not sure if I get the assertion suggestion. How would an assertion help here ? -- Qing ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r205024 - head/sys/net
I like Julian's suggestion because it is simple and very low risk. And there isn't a need to check for interface type any more. Here is why: 1. The interfaces that are popular and modern are already supporting link_state. So for these drivers, and there are just a few, I will go set its if_flags to include can change link_state. 2. For the existing dated drivers, because that flag bit is never set, no check is done. 3. In the mean time, we try to convert the drivers progressively. 4. If one wants to do ECMP and not having packets go into a black hole when the physical link is down, that person can ping the ML and ask for driver compatibility list. If we haven't converted that particular driver by then, we will update the driver if it's capable at that time. -- Qing On Fri, Mar 12, 2010 at 12:00 AM, Robert N. M. Watson rwat...@freebsd.org wrote: On Mar 12, 2010, at 7:52 AM, Qing Li wrote: Is there any way we can pick up via an assertion that an interface driver has failed to implement this functionality? This has never been a historic requirement, so I suspect there are a lot of drivers floating around that fail to meet the requirement. Also, is this for IFT_ETHER only, or also other link types? Not sure if I get the assertion suggestion. How would an assertion help here ? I think my proposal is similar to what Juli is suggesting: - Define a new interface capability for link state detection. - If a packet is sent or received on the interface, the capability is set, but the link state hasn't been set, panic. - If a packet is sent received on the interface, the capability isn't set, and the link state has been set, panic. That way the system blows up nicely and immediately, rather than dhclient simply never working, etc. Also, that way, testing for link state support is done at a point when we know the interface is live (a packet is sent or received). Finally, it means that code interested in link state isn't testing for one of (n) IFT_ types it thinks should have link state, but instead testing specifically whether the driver declares link state support. Of course, then you have to decide how to behave if a configured interface ECMP is running on doesn't support link state: the answer there is probably to assume it is always up, which would make this work for all those drivers that current fail to implement it. And if the hardware can't support link state, which some historic (and perhaps future) link types can't, things still work. Robert ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r205024 - head/sys/net
Nope, I meant Julian, and what he proposed, and if I understood correctly, is the simplest approach and easily done. -- Qing On Fri, Mar 12, 2010 at 12:29 AM, Robert N. M. Watson rwat...@freebsd.org wrote: On Mar 12, 2010, at 8:11 AM, Qing Li wrote: I like Julian's suggestion because it is simple and very low risk. And there isn't a need to check for interface type any more. Here is why: Re-reading this e-mail: perhaps you mean Juli, not Julian? ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r205077 - head/sys/net
Author: qingli Date: Fri Mar 12 10:24:58 2010 New Revision: 205077 URL: http://svn.freebsd.org/changeset/base/205077 Log: The flow-table module retrieves the destination and source address as well as the transport protocol port information from the outbound packets. The routing code is generic and compares every byte in the given sockaddr object. Therefore the temporary sockaddr objects must be cleared due to padding bytes. In addition, the port information must be stripped or the route search will either fail or return the incorrect route entry. Unit testing is done using OpenVPN over the if_tun interface. MFC after:7 days Modified: head/sys/net/flowtable.c Modified: head/sys/net/flowtable.c == --- head/sys/net/flowtable.cFri Mar 12 10:01:06 2010(r205076) +++ head/sys/net/flowtable.cFri Mar 12 10:24:58 2010(r205077) @@ -593,6 +593,8 @@ flowtable_lookup_mbuf4(struct flowtable dsin = (struct sockaddr_in *)dsa; ssin = (struct sockaddr_in *)ssa; + bzero(dsin, sizeof(*dsin)); + bzero(ssin, sizeof(*ssin)); flags = ft-ft_flags; if (ipv4_mbuf_demarshal(ft, m, ssin, dsin, flags) != 0) return (NULL); @@ -796,6 +798,8 @@ flowtable_lookup_mbuf6(struct flowtable dsin6 = (struct sockaddr_in6 *)dsa; ssin6 = (struct sockaddr_in6 *)ssa; + bzero(dsin6, sizeof(*dsin6)); + bzero(ssin6, sizeof(*ssin6)); flags = ft-ft_flags; if (ipv6_mbuf_demarshal(ft, m, ssin6, dsin6, flags) != 0) @@ -1088,6 +1092,14 @@ flowtable_lookup(struct flowtable *ft, s ro = sro; memcpy(ro-ro_dst, dsa, sizeof(struct sockaddr_in)); + /* +* The harvested source and destination addresses +* may contain port information if the packet is +* from a transport protocol (e.g. TCP/UDP). The +* port field must be cleared before performing +* a route lookup. +*/ + ((struct sockaddr_in *)ro-ro_dst)-sin_port = 0; dsin = (struct sockaddr_in *)dsa; ssin = (struct sockaddr_in *)ssa; if ((dsin-sin_addr.s_addr == ssin-sin_addr.s_addr) || @@ -1105,6 +1117,7 @@ flowtable_lookup(struct flowtable *ft, s ro = (struct route *)sro6; memcpy(sro6.ro_dst, dsa, sizeof(struct sockaddr_in6)); + ((struct sockaddr_in6 *)ro-ro_dst)-sin6_port = 0; dsin6 = (struct sockaddr_in6 *)dsa; ssin6 = (struct sockaddr_in6 *)ssa; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r205024 - head/sys/net
We've got LINK_STATE_UNKNOWN, we can just initialize if_link_state to this value in ether_ifattach(). And Qing should treat this value as LINK_STATE_UP in routing decision until better times. Thanks everyone for your input. I generally try to avoid overloading a variable to have more than 1 meaning. For example, the if_tun interface is in LINK_STATE_UNKNOWN until it's opened, then the link can be one of the other two states. Also, some of the pseudo drivers such as if_tun do not call ether_ifattach(). Right now I like to implement Robert's suggestion of using if_capabilities field. I'd like to create a new flag, IFCAP_LINKSTATE_NOTIFY flag. The routing decision will check against the if_link_state if this bit is set. Only a handful of drivers have this capability. So updating those drivers is a small task. Do we agree on this approach? -- Qing ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r205222 - in head: sbin/ifconfig sys/net
Author: qingli Date: Tue Mar 16 17:59:12 2010 New Revision: 205222 URL: http://svn.freebsd.org/changeset/base/205222 Log: Verify interface up status using its link state only if the interface has such capability. The interface capability flag indicates whether such capability exists. This approach is much more backward compatible. Physical device driver changes will be part of another commit. Also updated the ifconfig utility to show the LINKSTATE capability if present. Reviewed by: rwatson, imp, juli MFC after:3 days Modified: head/sbin/ifconfig/ifconfig.c head/sys/net/if.h head/sys/net/if_tap.c head/sys/net/if_tun.c head/sys/net/route.h Modified: head/sbin/ifconfig/ifconfig.c == --- head/sbin/ifconfig/ifconfig.c Tue Mar 16 17:45:16 2010 (r205221) +++ head/sbin/ifconfig/ifconfig.c Tue Mar 16 17:59:12 2010 (r205222) @@ -881,7 +881,7 @@ unsetifdescr(const char *val, int value, #defineIFCAPBITS \ \020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING \ \10VLAN_HWCSUM\11TSO4\12TSO6\13LRO\14WOL_UCAST\15WOL_MCAST\16WOL_MAGIC \ -\21VLAN_HWFILTER\23VLAN_HWTSO +\21VLAN_HWFILTER\23VLAN_HWTSO\24LINKSTATE /* * Print the status of the interface. If an address family was Modified: head/sys/net/if.h == --- head/sys/net/if.h Tue Mar 16 17:45:16 2010(r205221) +++ head/sys/net/if.h Tue Mar 16 17:59:12 2010(r205222) @@ -219,6 +219,7 @@ struct if_data { #defineIFCAP_VLAN_HWFILTER 0x1 /* interface hw can filter vlan tag */ #defineIFCAP_POLLING_NOCOUNT 0x2 /* polling ticks cannot be fragmented */ #defineIFCAP_VLAN_HWTSO0x4 /* can do IFCAP_TSO on VLANs */ +#defineIFCAP_LINKSTATE 0x8 /* the runtime link state is dynamic */ #define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM) #defineIFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6) Modified: head/sys/net/if_tap.c == --- head/sys/net/if_tap.c Tue Mar 16 17:45:16 2010(r205221) +++ head/sys/net/if_tap.c Tue Mar 16 17:59:12 2010(r205222) @@ -443,6 +443,8 @@ tapcreate(struct cdev *dev) ifp-if_mtu = ETHERMTU; ifp-if_flags = (IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST); ifp-if_snd.ifq_maxlen = ifqmaxlen; + ifp-if_capabilities |= IFCAP_LINKSTATE; + ifp-if_capenable |= IFCAP_LINKSTATE; dev-si_drv1 = tp; tp-tap_dev = dev; Modified: head/sys/net/if_tun.c == --- head/sys/net/if_tun.c Tue Mar 16 17:45:16 2010(r205221) +++ head/sys/net/if_tun.c Tue Mar 16 17:59:12 2010(r205222) @@ -386,6 +386,8 @@ tuncreate(const char *name, struct cdev ifp-if_snd.ifq_drv_maxlen = 0; IFQ_SET_READY(ifp-if_snd); knlist_init_mtx(sc-tun_rsel.si_note, NULL); + ifp-if_capabilities |= IFCAP_LINKSTATE; + ifp-if_capenable |= IFCAP_LINKSTATE; if_attach(ifp); bpfattach(ifp, DLT_NULL, sizeof(u_int32_t)); Modified: head/sys/net/route.h == --- head/sys/net/route.hTue Mar 16 17:45:16 2010(r205221) +++ head/sys/net/route.hTue Mar 16 17:59:12 2010(r205222) @@ -319,8 +319,7 @@ struct rt_addrinfo { #ifdef _KERNEL -#define RT_LINK_IS_UP(ifp) (((ifp)-if_flags \ - (IFF_LOOPBACK | IFF_POINTOPOINT)) \ +#define RT_LINK_IS_UP(ifp) (!((ifp)-if_capabilities IFCAP_LINKSTATE) \ || (ifp)-if_link_state == LINK_STATE_UP) #defineRT_LOCK_INIT(_rt) \ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r205268 - head/sys/dev/mii
Author: qingli Date: Wed Mar 17 22:12:12 2010 New Revision: 205268 URL: http://svn.freebsd.org/changeset/base/205268 Log: Set the device capabilities to include dynamic link-state for those modern drivers. Reviewed by: imp (and suggested by imp) MFC after:3 days Modified: head/sys/dev/mii/mii.c Modified: head/sys/dev/mii/mii.c == --- head/sys/dev/mii/mii.c Wed Mar 17 21:19:30 2010(r205267) +++ head/sys/dev/mii/mii.c Wed Mar 17 22:12:12 2010(r205268) @@ -173,6 +173,8 @@ miibus_attach(device_t dev) * XXX: EVIL HACK! */ mii-mii_ifp = *(struct ifnet**)device_get_softc(device_get_parent(dev)); + mii-mii_ifp-if_capabilities |= IFCAP_LINKSTATE; + mii-mii_ifp-if_capenable |= IFCAP_LINKSTATE; ivars = device_get_ivars(dev); ifmedia_init(mii-mii_media, IFM_IMASK, ivars-ifmedia_upd, ivars-ifmedia_sts); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r205272 - head/usr.sbin/ppp
Author: qingli Date: Thu Mar 18 00:23:39 2010 New Revision: 205272 URL: http://svn.freebsd.org/changeset/base/205272 Log: Need to set the proper flag bit when inserting ARP entries into the kernel. MFC after:3 days Modified: head/usr.sbin/ppp/arp.c Modified: head/usr.sbin/ppp/arp.c == --- head/usr.sbin/ppp/arp.c Wed Mar 17 22:57:58 2010(r205271) +++ head/usr.sbin/ppp/arp.c Thu Mar 18 00:23:39 2010(r205272) @@ -119,7 +119,7 @@ arp_ProxySub(struct bundle *bundle, stru return 0; } arpmsg.hdr.rtm_type = add ? RTM_ADD : RTM_DELETE; - arpmsg.hdr.rtm_flags = RTF_ANNOUNCE | RTF_HOST | RTF_STATIC; + arpmsg.hdr.rtm_flags = RTF_ANNOUNCE | RTF_HOST | RTF_STATIC | RTF_LLDATA; arpmsg.hdr.rtm_version = RTM_VERSION; arpmsg.hdr.rtm_seq = ++bundle-routing_seq; arpmsg.hdr.rtm_addrs = RTA_DST | RTA_GATEWAY; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r205493 - in stable/8/usr.sbin: . dumpcis makefs makefs/ffs mfiutil ppp
Author: qingli Date: Mon Mar 22 23:33:40 2010 New Revision: 205493 URL: http://svn.freebsd.org/changeset/base/205493 Log: MFC r205272 Need to set the proper flag bit when inserting ARP entries into the kernel. Modified: stable/8/usr.sbin/ppp/arp.c Directory Properties: stable/8/usr.sbin/ (props changed) stable/8/usr.sbin/Makefile (props changed) stable/8/usr.sbin/acpi/ (props changed) stable/8/usr.sbin/arp/ (props changed) stable/8/usr.sbin/bsnmpd/ (props changed) stable/8/usr.sbin/burncd/ (props changed) stable/8/usr.sbin/cdcontrol/ (props changed) stable/8/usr.sbin/cpucontrol/ (props changed) stable/8/usr.sbin/crashinfo/ (props changed) stable/8/usr.sbin/cron/ (props changed) stable/8/usr.sbin/diskinfo/ (props changed) stable/8/usr.sbin/dumpcis/cardinfo.h (props changed) stable/8/usr.sbin/dumpcis/cis.h (props changed) stable/8/usr.sbin/faithd/ (props changed) stable/8/usr.sbin/freebsd-update/ (props changed) stable/8/usr.sbin/inetd/ (props changed) stable/8/usr.sbin/iostat/ (props changed) stable/8/usr.sbin/jail/ (props changed) stable/8/usr.sbin/jls/ (props changed) stable/8/usr.sbin/lpr/ (props changed) stable/8/usr.sbin/makefs/ffs/ffs_bswap.c (props changed) stable/8/usr.sbin/makefs/ffs/ffs_subr.c (props changed) stable/8/usr.sbin/makefs/ffs/ufs_bswap.h (props changed) stable/8/usr.sbin/makefs/getid.c (props changed) stable/8/usr.sbin/mergemaster/ (props changed) stable/8/usr.sbin/mfiutil/mfiutil.8 (props changed) stable/8/usr.sbin/mptutil/ (props changed) stable/8/usr.sbin/ndp/ (props changed) stable/8/usr.sbin/newsyslog/ (props changed) stable/8/usr.sbin/ntp/ (props changed) stable/8/usr.sbin/pmcstat/ (props changed) stable/8/usr.sbin/powerd/ (props changed) stable/8/usr.sbin/ppp/ (props changed) stable/8/usr.sbin/pstat/ (props changed) stable/8/usr.sbin/rpc.umntall/ (props changed) stable/8/usr.sbin/rtsold/ (props changed) stable/8/usr.sbin/service/ (props changed) stable/8/usr.sbin/sysinstall/ (props changed) stable/8/usr.sbin/syslogd/ (props changed) stable/8/usr.sbin/traceroute/ (props changed) stable/8/usr.sbin/traceroute6/ (props changed) stable/8/usr.sbin/usbconfig/ (props changed) stable/8/usr.sbin/wpa/ (props changed) stable/8/usr.sbin/ypserv/ (props changed) stable/8/usr.sbin/zic/ (props changed) Modified: stable/8/usr.sbin/ppp/arp.c == --- stable/8/usr.sbin/ppp/arp.c Mon Mar 22 23:31:48 2010(r205492) +++ stable/8/usr.sbin/ppp/arp.c Mon Mar 22 23:33:40 2010(r205493) @@ -119,7 +119,7 @@ arp_ProxySub(struct bundle *bundle, stru return 0; } arpmsg.hdr.rtm_type = add ? RTM_ADD : RTM_DELETE; - arpmsg.hdr.rtm_flags = RTF_ANNOUNCE | RTF_HOST | RTF_STATIC; + arpmsg.hdr.rtm_flags = RTF_ANNOUNCE | RTF_HOST | RTF_STATIC | RTF_LLDATA; arpmsg.hdr.rtm_version = RTM_VERSION; arpmsg.hdr.rtm_seq = ++bundle-routing_seq; arpmsg.hdr.rtm_addrs = RTA_DST | RTA_GATEWAY; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r206055 - stable/8/sys/net
Author: qingli Date: Thu Apr 1 20:23:43 2010 New Revision: 206055 URL: http://svn.freebsd.org/changeset/base/206055 Log: MFC 205077 The flow-table module retrieves the destination and source address as well as the transport protocol port information from the outbound packets. The routing code is generic and compares every byte in the given sockaddr object. Therefore the temporary sockaddr objects must be cleared due to padding bytes. In addition, the port information must be stripped or the route search will either fail or return the incorrect route entry. Unit testing is done using OpenVPN over the if_tun interface. Modified: stable/8/sys/net/flowtable.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/ (props changed) Modified: stable/8/sys/net/flowtable.c == --- stable/8/sys/net/flowtable.cThu Apr 1 19:05:43 2010 (r206054) +++ stable/8/sys/net/flowtable.cThu Apr 1 20:23:43 2010 (r206055) @@ -598,6 +598,8 @@ flowtable_lookup_mbuf4(struct flowtable dsin = (struct sockaddr_in *)dsa; ssin = (struct sockaddr_in *)ssa; + bzero(dsin, sizeof(*dsin)); + bzero(ssin, sizeof(*ssin)); flags = ft-ft_flags; if (ipv4_mbuf_demarshal(ft, m, ssin, dsin, flags) != 0) return (NULL); @@ -801,6 +803,8 @@ flowtable_lookup_mbuf6(struct flowtable dsin6 = (struct sockaddr_in6 *)dsa; ssin6 = (struct sockaddr_in6 *)ssa; + bzero(dsin6, sizeof(*dsin6)); + bzero(ssin6, sizeof(*ssin6)); flags = ft-ft_flags; if (ipv6_mbuf_demarshal(ft, m, ssin6, dsin6, flags) != 0) @@ -1130,6 +1134,14 @@ flowtable_lookup(struct flowtable *ft, s ro = sro; memcpy(ro-ro_dst, dsa, sizeof(struct sockaddr_in)); + /* +* The harvested source and destination addresses +* may contain port information if the packet is +* from a transport protocol (e.g. TCP/UDP). The +* port field must be cleared before performing +* a route lookup. +*/ + ((struct sockaddr_in *)ro-ro_dst)-sin_port = 0; dsin = (struct sockaddr_in *)dsa; ssin = (struct sockaddr_in *)ssa; if ((dsin-sin_addr.s_addr == ssin-sin_addr.s_addr) || @@ -1147,6 +1159,7 @@ flowtable_lookup(struct flowtable *ft, s ro = (struct route *)sro6; memcpy(sro6.ro_dst, dsa, sizeof(struct sockaddr_in6)); + ((struct sockaddr_in6 *)ro-ro_dst)-sin6_port = 0; dsin6 = (struct sockaddr_in6 *)dsa; ssin6 = (struct sockaddr_in6 *)ssa; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r206066 - stable/8/sys/netinet
Author: qingli Date: Fri Apr 2 04:58:17 2010 New Revision: 206066 URL: http://svn.freebsd.org/changeset/base/206066 Log: MFC 201131 introduce a local variable rte acting as a cache of ro-ro_rt within ip_output, achieving (in random order of importance): - a reduction of the number of 'r's in the source code; - improved legibility; - a reduction of 64 bytes in the .text Modified: stable/8/sys/netinet/ip_output.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/ (props changed) Modified: stable/8/sys/netinet/ip_output.c == --- stable/8/sys/netinet/ip_output.cFri Apr 2 04:42:02 2010 (r206065) +++ stable/8/sys/netinet/ip_output.cFri Apr 2 04:58:17 2010 (r206066) @@ -128,6 +128,7 @@ ip_output(struct mbuf *m, struct mbuf *o struct in_ifaddr *ia = NULL; int isbroadcast, sw_csum; struct route iproute; + struct rtentry *rte;/* cache for ro-ro_rt */ struct in_addr odst; #ifdef IPFIREWALL_FORWARD struct m_tag *fwd_tag = NULL; @@ -205,18 +206,19 @@ again: * The address family should also be checked in case of sharing the * cache with IPv6. */ - if (ro-ro_rt ((ro-ro_rt-rt_flags RTF_UP) == 0 || + rte = ro-ro_rt; + if (rte ((rte-rt_flags RTF_UP) == 0 || dst-sin_family != AF_INET || dst-sin_addr.s_addr != ip-ip_dst.s_addr)) { if (!nortfree) - RTFREE(ro-ro_rt); - ro-ro_rt = (struct rtentry *)NULL; + RTFREE(rte); + rte = ro-ro_rt = (struct rtentry *)NULL; ro-ro_lle = (struct llentry *)NULL; } #ifdef IPFIREWALL_FORWARD - if (ro-ro_rt == NULL fwd_tag == NULL) { + if (rte == NULL fwd_tag == NULL) { #else - if (ro-ro_rt == NULL) { + if (rte == NULL) { #endif bzero(dst, sizeof(*dst)); dst-sin_family = AF_INET; @@ -266,7 +268,7 @@ again: * as this is probably required in all cases for correct * operation (as it is for ARP). */ - if (ro-ro_rt == NULL) + if (rte == NULL) { #ifdef RADIX_MPATH rtalloc_mpath_fib(ro, ntohl(ip-ip_src.s_addr ^ ip-ip_dst.s_addr), @@ -275,7 +277,9 @@ again: in_rtalloc_ign(ro, 0, inp ? inp-inp_inc.inc_fibnum : M_GETFIB(m)); #endif - if (ro-ro_rt == NULL) { + rte = ro-ro_rt; + } + if (rte == NULL) { #ifdef IPSEC /* * There is no route for this packet, but it is @@ -289,14 +293,14 @@ again: error = EHOSTUNREACH; goto bad; } - ia = ifatoia(ro-ro_rt-rt_ifa); + ia = ifatoia(rte-rt_ifa); ifa_ref(ia-ia_ifa); - ifp = ro-ro_rt-rt_ifp; - ro-ro_rt-rt_rmx.rmx_pksent++; - if (ro-ro_rt-rt_flags RTF_GATEWAY) - dst = (struct sockaddr_in *)ro-ro_rt-rt_gateway; - if (ro-ro_rt-rt_flags RTF_HOST) - isbroadcast = (ro-ro_rt-rt_flags RTF_BROADCAST); + ifp = rte-rt_ifp; + rte-rt_rmx.rmx_pksent++; + if (rte-rt_flags RTF_GATEWAY) + dst = (struct sockaddr_in *)rte-rt_gateway; + if (rte-rt_flags RTF_HOST) + isbroadcast = (rte-rt_flags RTF_BROADCAST); else isbroadcast = in_broadcast(dst-sin_addr, ifp); } @@ -304,7 +308,7 @@ again: * Calculate MTU. If we have a route that is up, use that, * otherwise use the interface's MTU. */ - if (ro-ro_rt != NULL (ro-ro_rt-rt_flags (RTF_UP|RTF_HOST))) { + if (rte != NULL (rte-rt_flags (RTF_UP|RTF_HOST))) { /* * This case can happen if the user changed the MTU * of an interface after enabling IP on it. Because @@ -312,9 +316,9 @@ again: * them, there is no way for one to update all its * routes when the MTU is changed. */ - if (ro-ro_rt-rt_rmx.rmx_mtu ifp-if_mtu) - ro-ro_rt-rt_rmx.rmx_mtu = ifp-if_mtu; - mtu = ro-ro_rt-rt_rmx.rmx_mtu; + if (rte-rt_rmx.rmx_mtu ifp-if_mtu) + rte-rt_rmx.rmx_mtu =
svn commit: r206067 - in stable/8/sys: net netinet
Author: qingli Date: Fri Apr 2 05:02:50 2010 New Revision: 206067 URL: http://svn.freebsd.org/changeset/base/206067 Log: MFC 204902 One of the advantages of enabling ECMP (a.k.a RADIX_MPATH) is to allow for connection load balancing across interfaces. Currently the address alias handling method is colliding with the ECMP code. For example, when two interfaces are configured on the same prefix, only one prefix route is installed. So connection load balancing among the available interfaces is not possible. The other advantage of ECMP is for failover. The issue with the current code, is that the interface link-state is not reflected in the route entry. For example, if there are two interfaces on the same prefix, the cable on one interface is unplugged, new and existing connections should switch over to the other interface. This is not done today and packets go into a black hole. Also, there is a small bug in the kernel where deleting ECMP routes in the userland will always return an error even though the command is successfully executed. Modified: stable/8/sys/net/flowtable.c stable/8/sys/net/radix.c stable/8/sys/net/radix_mpath.c stable/8/sys/net/route.c stable/8/sys/net/route.h stable/8/sys/netinet/in.c stable/8/sys/netinet/ip_output.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/ (props changed) Modified: stable/8/sys/net/flowtable.c == --- stable/8/sys/net/flowtable.cFri Apr 2 04:58:17 2010 (r206066) +++ stable/8/sys/net/flowtable.cFri Apr 2 05:02:50 2010 (r206067) @@ -870,7 +870,8 @@ flow_stale(struct flowtable *ft, struct || ((fle-f_rt-rt_flags RTF_HOST) ((fle-f_rt-rt_flags (RTF_UP)) != (RTF_UP))) - || (fle-f_rt-rt_ifp == NULL)) + || (fle-f_rt-rt_ifp == NULL) + || !RT_LINK_IS_UP(fle-f_rt-rt_ifp)) return (1); idle_time = time_uptime - fle-f_uptime; Modified: stable/8/sys/net/radix.c == --- stable/8/sys/net/radix.cFri Apr 2 04:58:17 2010(r206066) +++ stable/8/sys/net/radix.cFri Apr 2 05:02:50 2010(r206067) @@ -761,8 +761,10 @@ on2: if (m-rm_flags RNF_NORMAL) { mmask = m-rm_leaf-rn_mask; if (tt-rn_flags RNF_NORMAL) { +#if !defined(RADIX_MPATH) log(LOG_ERR, Non-unique normal route, mask not entered\n); +#endif return tt; } } else Modified: stable/8/sys/net/radix_mpath.c == --- stable/8/sys/net/radix_mpath.c Fri Apr 2 04:58:17 2010 (r206066) +++ stable/8/sys/net/radix_mpath.c Fri Apr 2 05:02:50 2010 (r206067) @@ -270,7 +270,8 @@ rtalloc_mpath_fib(struct route *ro, uint * XXX we don't attempt to lookup cached route again; what should * be done for sendto(3) case? */ - if (ro-ro_rt ro-ro_rt-rt_ifp (ro-ro_rt-rt_flags RTF_UP)) + if (ro-ro_rt ro-ro_rt-rt_ifp (ro-ro_rt-rt_flags RTF_UP) +RT_LINK_IS_UP(ro-ro_rt-rt_ifp)) return; ro-ro_rt = rtalloc1_fib(ro-ro_dst, 1, 0, fibnum); Modified: stable/8/sys/net/route.c == --- stable/8/sys/net/route.cFri Apr 2 04:58:17 2010(r206066) +++ stable/8/sys/net/route.cFri Apr 2 05:02:50 2010(r206067) @@ -830,7 +830,13 @@ rt_getifa_fib(struct rt_addrinfo *info, int rtexpunge(struct rtentry *rt) { +#if !defined(RADIX_MPATH) struct radix_node *rn; +#else + struct rt_addrinfo info; + int fib; + struct rtentry *rt0; +#endif struct radix_node_head *rnh; struct ifaddr *ifa; int error = 0; @@ -843,14 +849,26 @@ rtexpunge(struct rtentry *rt) if (rnh == NULL) return (EAFNOSUPPORT); RADIX_NODE_HEAD_LOCK_ASSERT(rnh); -#if 0 - /* -* We cannot assume anything about the reference count -* because protocols call us in many situations; often -* before unwinding references to the table entry. -*/ - KASSERT(rt-rt_refcnt = 1, (bogus refcnt %ld, rt-rt_refcnt)); -#endif + +#ifdef RADIX_MPATH + fib = rt-rt_fibnum; + bzero(info, sizeof(info)); + info.rti_ifp = rt-rt_ifp; + info.rti_flags =
svn commit: r206068 - stable/8/sys/net
Author: qingli Date: Fri Apr 2 05:05:51 2010 New Revision: 206068 URL: http://svn.freebsd.org/changeset/base/206068 Log: MFC 205024 The if_tap interface is of IFT_ETHERNET type, but it does not set or update the if_link_state variable. As such RT_LINK_IS_UP() fails for the if_tap interface. Also, the RT_LINK_IS_UP() needs to bypass all loopback interfaces because loopback interfaces are considered up logically as long as the system is running. This patch fixes the above issues by setting and updating the if_link_state variable when the tap interface is opened or closed respectively. Similary approach is already done in the if_tun device. Modified: stable/8/sys/net/if_tap.c stable/8/sys/net/route.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/ (props changed) Modified: stable/8/sys/net/if_tap.c == --- stable/8/sys/net/if_tap.c Fri Apr 2 05:02:50 2010(r206067) +++ stable/8/sys/net/if_tap.c Fri Apr 2 05:05:51 2010(r206068) @@ -502,6 +502,7 @@ tapopen(struct cdev *dev, int flag, int ifp-if_drv_flags = ~IFF_DRV_OACTIVE; if (tapuponopen) ifp-if_flags |= IFF_UP; + if_link_state_change(ifp, LINK_STATE_UP); splx(s); TAPDEBUG(%s is open. minor = %#x\n, ifp-if_xname, dev2unit(dev)); @@ -547,6 +548,7 @@ tapclose(struct cdev *dev, int foo, int } else mtx_unlock(tp-tap_mtx); + if_link_state_change(ifp, LINK_STATE_DOWN); funsetown(tp-tap_sigio); selwakeuppri(tp-tap_rsel, PZERO+1); KNOTE_UNLOCKED(tp-tap_rsel.si_note, 0); Modified: stable/8/sys/net/route.h == --- stable/8/sys/net/route.hFri Apr 2 05:02:50 2010(r206067) +++ stable/8/sys/net/route.hFri Apr 2 05:05:51 2010(r206068) @@ -319,7 +319,9 @@ struct rt_addrinfo { #ifdef _KERNEL -#define RT_LINK_IS_UP(ifp) ((ifp)-if_link_state == LINK_STATE_UP) +#define RT_LINK_IS_UP(ifp) (((ifp)-if_flags \ + (IFF_LOOPBACK | IFF_POINTOPOINT)) \ +|| (ifp)-if_link_state == LINK_STATE_UP) #defineRT_LOCK_INIT(_rt) \ mtx_init((_rt)-rt_mtx, rtentry, NULL, MTX_DEF | MTX_DUPOK) ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r206069 - in stable/8: sbin/ifconfig sys/net
Author: qingli Date: Fri Apr 2 05:12:46 2010 New Revision: 206069 URL: http://svn.freebsd.org/changeset/base/206069 Log: MFC 205222 Verify interface up status using its link state only if the interface has such capability. The interface capability flag indicates whether such capability exists. This approach is much more backward compatible. Physical device driver changes will be part of another commit. Also updated the ifconfig utility to show the LINKSTATE capability if present. Reviewed by: rwatson, imp, juli Modified: stable/8/sbin/ifconfig/ifconfig.c stable/8/sys/net/if.h stable/8/sys/net/if_tap.c stable/8/sys/net/if_tun.c stable/8/sys/net/route.h Directory Properties: stable/8/sbin/ (props changed) stable/8/sbin/atacontrol/ (props changed) stable/8/sbin/bsdlabel/ (props changed) stable/8/sbin/camcontrol/ (props changed) stable/8/sbin/ddb/ (props changed) stable/8/sbin/devfs/ (props changed) stable/8/sbin/dhclient/ (props changed) stable/8/sbin/dump/ (props changed) stable/8/sbin/dumpfs/ (props changed) stable/8/sbin/fsck/ (props changed) stable/8/sbin/fsck_ffs/ (props changed) stable/8/sbin/geom/ (props changed) stable/8/sbin/geom/class/stripe/ (props changed) stable/8/sbin/ggate/ (props changed) stable/8/sbin/growfs/ (props changed) stable/8/sbin/ifconfig/ (props changed) stable/8/sbin/ipfw/ (props changed) stable/8/sbin/iscontrol/ (props changed) stable/8/sbin/mdconfig/ (props changed) stable/8/sbin/mksnap_ffs/ (props changed) stable/8/sbin/mount/ (props changed) stable/8/sbin/mount_cd9660/ (props changed) stable/8/sbin/mount_msdosfs/ (props changed) stable/8/sbin/mount_nfs/ (props changed) stable/8/sbin/natd/ (props changed) stable/8/sbin/newfs/ (props changed) stable/8/sbin/restore/ (props changed) stable/8/sbin/routed/ (props changed) stable/8/sbin/sysctl/ (props changed) stable/8/sbin/tunefs/ (props changed) stable/8/sbin/umount/ (props changed) stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/ (props changed) Modified: stable/8/sbin/ifconfig/ifconfig.c == --- stable/8/sbin/ifconfig/ifconfig.c Fri Apr 2 05:05:51 2010 (r206068) +++ stable/8/sbin/ifconfig/ifconfig.c Fri Apr 2 05:12:46 2010 (r206069) @@ -865,7 +865,7 @@ unsetifdescr(const char *val, int value, #defineIFCAPBITS \ \020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING \ \10VLAN_HWCSUM\11TSO4\12TSO6\13LRO\14WOL_UCAST\15WOL_MCAST\16WOL_MAGIC \ -\21VLAN_HWFILTER\23VLAN_HWTSO +\21VLAN_HWFILTER\23VLAN_HWTSO\24LINKSTATE /* * Print the status of the interface. If an address family was Modified: stable/8/sys/net/if.h == --- stable/8/sys/net/if.h Fri Apr 2 05:05:51 2010(r206068) +++ stable/8/sys/net/if.h Fri Apr 2 05:12:46 2010(r206069) @@ -219,6 +219,7 @@ struct if_data { #defineIFCAP_VLAN_HWFILTER 0x1 /* interface hw can filter vlan tag */ #defineIFCAP_POLLING_NOCOUNT 0x2 /* polling ticks cannot be fragmented */ #defineIFCAP_VLAN_HWTSO0x4 /* can do IFCAP_TSO on VLANs */ +#defineIFCAP_LINKSTATE 0x8 /* the runtime link state is dynamic */ #define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM) #defineIFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6) Modified: stable/8/sys/net/if_tap.c == --- stable/8/sys/net/if_tap.c Fri Apr 2 05:05:51 2010(r206068) +++ stable/8/sys/net/if_tap.c Fri Apr 2 05:12:46 2010(r206069) @@ -443,6 +443,8 @@ tapcreate(struct cdev *dev) ifp-if_mtu = ETHERMTU; ifp-if_flags = (IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST); ifp-if_snd.ifq_maxlen = ifqmaxlen; + ifp-if_capabilities |= IFCAP_LINKSTATE; + ifp-if_capenable |= IFCAP_LINKSTATE; dev-si_drv1 = tp; tp-tap_dev = dev; Modified: stable/8/sys/net/if_tun.c == --- stable/8/sys/net/if_tun.c Fri Apr 2 05:05:51 2010(r206068) +++ stable/8/sys/net/if_tun.c Fri Apr 2 05:12:46 2010(r206069) @@ -386,6 +386,8 @@ tuncreate(const char *name, struct cdev ifp-if_snd.ifq_drv_maxlen = 0; IFQ_SET_READY(ifp-if_snd); knlist_init_mtx(sc-tun_rsel.si_note, NULL); + ifp-if_capabilities |= IFCAP_LINKSTATE; + ifp-if_capenable |= IFCAP_LINKSTATE; if_attach(ifp);
svn commit: r206071 - stable/8/sys/dev/mii
Author: qingli Date: Fri Apr 2 05:15:27 2010 New Revision: 206071 URL: http://svn.freebsd.org/changeset/base/206071 Log: MFC 205268 Set the device capabilities to include dynamic link-state for those modern drivers. Reviewed by: imp (and suggested by imp) Modified: stable/8/sys/dev/mii/mii.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/net/ (props changed) Modified: stable/8/sys/dev/mii/mii.c == --- stable/8/sys/dev/mii/mii.c Fri Apr 2 05:14:57 2010(r206070) +++ stable/8/sys/dev/mii/mii.c Fri Apr 2 05:15:27 2010(r206071) @@ -180,6 +180,8 @@ miibus_attach(device_t dev) * XXX: EVIL HACK! */ mii-mii_ifp = *(struct ifnet**)device_get_softc(device_get_parent(dev)); + mii-mii_ifp-if_capabilities |= IFCAP_LINKSTATE; + mii-mii_ifp-if_capenable |= IFCAP_LINKSTATE; ivars = device_get_ivars(dev); ifmedia_init(mii-mii_media, IFM_IMASK, ivars-ifmedia_upd, ivars-ifmedia_sts); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r186153 - head/sys/netinet6
Author: qingli Date: Tue Dec 16 01:21:19 2008 New Revision: 186153 URL: http://svn.freebsd.org/changeset/base/186153 Log: Initialize the variable router, and apply static_route flag across the entire nd6_cache_lladdr() function. Modified: head/sys/netinet6/nd6.c Modified: head/sys/netinet6/nd6.c == --- head/sys/netinet6/nd6.c Tue Dec 16 01:18:10 2008(r186152) +++ head/sys/netinet6/nd6.c Tue Dec 16 01:21:19 2008(r186153) @@ -1405,9 +1405,10 @@ nd6_cache_lladdr(struct ifnet *ifp, stru int llchange; int flags = 0; int newstate = 0; - uint16_t router; + uint16_t router = 0; struct sockaddr_in6 sin6; struct mbuf *chain = NULL; + int static_route = 0; IF_AFDATA_UNLOCK_ASSERT(ifp); @@ -1441,8 +1442,10 @@ nd6_cache_lladdr(struct ifnet *ifp, stru is_newentry = 1; } else { /* do nothing if static ndp is set */ - if (ln-la_flags LLE_STATIC) + if (ln-la_flags LLE_STATIC) { + static_route = 1; goto done; + } is_newentry = 0; } if (ln == NULL) @@ -1600,7 +1603,7 @@ nd6_cache_lladdr(struct ifnet *ifp, stru } if (ln) { - int static_route = (ln-la_flags LLE_STATIC); + static_route = (ln-la_flags LLE_STATIC); router = ln-ln_router; if (flags ND6_EXCLUSIVE) @@ -1642,7 +1645,7 @@ done: LLE_WUNLOCK(ln); else LLE_RUNLOCK(ln); - if (ln-la_flags LLE_STATIC) + if (static_route) ln = NULL; } return (ln); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r186217 - in head/sys: net netinet6
Author: qingli Date: Wed Dec 17 10:27:34 2008 New Revision: 186217 URL: http://svn.freebsd.org/changeset/base/186217 Log: Remove the rt argument from nd6_storelladdr() because rt is no longer accessed. Modified: head/sys/net/if_arcsubr.c head/sys/net/if_ethersubr.c head/sys/net/if_fddisubr.c head/sys/net/if_fwsubr.c head/sys/net/if_iso88025subr.c head/sys/netinet6/nd6_rtr.c Modified: head/sys/net/if_arcsubr.c == --- head/sys/net/if_arcsubr.c Wed Dec 17 10:19:53 2008(r186216) +++ head/sys/net/if_arcsubr.c Wed Dec 17 10:27:34 2008(r186217) @@ -167,7 +167,7 @@ arc_output(struct ifnet *ifp, struct mbu #endif #ifdef INET6 case AF_INET6: - error = nd6_storelladdr(ifp, rt0, m, dst, (u_char *)adst, lle); + error = nd6_storelladdr(ifp, m, dst, (u_char *)adst, lle); if (error) return (error); atype = ARCTYPE_INET6; Modified: head/sys/net/if_ethersubr.c == --- head/sys/net/if_ethersubr.c Wed Dec 17 10:19:53 2008(r186216) +++ head/sys/net/if_ethersubr.c Wed Dec 17 10:27:34 2008(r186217) @@ -225,7 +225,7 @@ ether_output(struct ifnet *ifp, struct m #endif #ifdef INET6 case AF_INET6: - error = nd6_storelladdr(ifp, rt0, m, dst, (u_char *)edst, lle); + error = nd6_storelladdr(ifp, m, dst, (u_char *)edst, lle); if (error) return error; type = htons(ETHERTYPE_IPV6); Modified: head/sys/net/if_fddisubr.c == --- head/sys/net/if_fddisubr.c Wed Dec 17 10:19:53 2008(r186216) +++ head/sys/net/if_fddisubr.c Wed Dec 17 10:27:34 2008(r186217) @@ -175,7 +175,7 @@ fddi_output(ifp, m, dst, rt0) #endif /* INET */ #ifdef INET6 case AF_INET6: - error = nd6_storelladdr(ifp, rt0, m, dst, (u_char *)edst, lle); + error = nd6_storelladdr(ifp, m, dst, (u_char *)edst, lle); if (error) return (error); /* Something bad happened */ type = htons(ETHERTYPE_IPV6); Modified: head/sys/net/if_fwsubr.c == --- head/sys/net/if_fwsubr.cWed Dec 17 10:19:53 2008(r186216) +++ head/sys/net/if_fwsubr.cWed Dec 17 10:27:34 2008(r186217) @@ -167,7 +167,7 @@ firewire_output(struct ifnet *ifp, struc #ifdef INET6 case AF_INET6: if (unicast) { - error = nd6_storelladdr(fc-fc_ifp, rt0, m, dst, + error = nd6_storelladdr(fc-fc_ifp, m, dst, (u_char *) destfw, lle); if (error) return (error); Modified: head/sys/net/if_iso88025subr.c == --- head/sys/net/if_iso88025subr.c Wed Dec 17 10:19:53 2008 (r186216) +++ head/sys/net/if_iso88025subr.c Wed Dec 17 10:27:34 2008 (r186217) @@ -319,7 +319,7 @@ iso88025_output(ifp, m, dst, rt0) #endif /* INET */ #ifdef INET6 case AF_INET6: - error = nd6_storelladdr(ifp, rt0, m, dst, (u_char *)edst, lle); + error = nd6_storelladdr(ifp, m, dst, (u_char *)edst, lle); if (error) return (error); snap_type = ETHERTYPE_IPV6; Modified: head/sys/netinet6/nd6_rtr.c == --- head/sys/netinet6/nd6_rtr.c Wed Dec 17 10:19:53 2008(r186216) +++ head/sys/netinet6/nd6_rtr.c Wed Dec 17 10:27:34 2008(r186217) @@ -1554,7 +1554,6 @@ nd6_prefix_onlink(struct nd_prefix *pr) char ip6buf[INET6_ADDRSTRLEN]; struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK}; - /* sanity check */ if ((pr-ndpr_stateflags NDPRF_ONLINK) != 0) { nd6log((LOG_ERR, @@ -1623,7 +1622,6 @@ nd6_prefix_onlink(struct nd_prefix *pr) rtflags = ifa-ifa_flags | RTF_UP; error = rtrequest(RTM_ADD, (struct sockaddr *)pr-ndpr_prefix, ifa-ifa_addr, (struct sockaddr *)mask6, rtflags, rt); - if (error == 0) { if (rt != NULL) /* this should be non NULL, though */ { rnh = V_rt_tables[rt-rt_fibnum][AF_INET6]; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r186216 - head/sys/netinet6
Author: qingli Date: Wed Dec 17 10:19:53 2008 New Revision: 186216 URL: http://svn.freebsd.org/changeset/base/186216 Log: A couple of files were not meant to be committed. Modified: head/sys/netinet6/in6.c head/sys/netinet6/nd6_rtr.c Modified: head/sys/netinet6/in6.c == --- head/sys/netinet6/in6.c Wed Dec 17 10:03:49 2008(r186215) +++ head/sys/netinet6/in6.c Wed Dec 17 10:19:53 2008(r186216) @@ -987,13 +987,6 @@ in6_update_ifa(struct ifnet *ifp, struct } } if (!rt) { - - printf(in6_update_ifa #1: addr= %s, mask= %s, ia= %s, ifp = %s\n, - ip6_sprintf(ip6buf, mltaddr.sin6_addr), - ip6_sprintf(ip6buf, mltmask.sin6_addr), - ip6_sprintf(ip6buf, ia-ia_addr.sin6_addr), - if_name(ifp)); - error = rtrequest(RTM_ADD, (struct sockaddr *)mltaddr, (struct sockaddr *)ia-ia_addr, (struct sockaddr *)mltmask, RTF_UP, @@ -1068,12 +1061,6 @@ in6_update_ifa(struct ifnet *ifp, struct } } if (!rt) { - printf(in6_update_ifa #2: addr= %s, mask= %s, ia= %s, ifp = %s\n, - ip6_sprintf(ip6buf, mltaddr.sin6_addr), - ip6_sprintf(ip6buf, mltmask.sin6_addr), - ip6_sprintf(ip6buf, ia-ia_addr.sin6_addr), - if_name(ifp)); - error = rtrequest(RTM_ADD, (struct sockaddr *)mltaddr, (struct sockaddr *)ia-ia_addr, (struct sockaddr *)mltmask, RTF_UP, Modified: head/sys/netinet6/nd6_rtr.c == --- head/sys/netinet6/nd6_rtr.c Wed Dec 17 10:03:49 2008(r186215) +++ head/sys/netinet6/nd6_rtr.c Wed Dec 17 10:19:53 2008(r186216) @@ -1555,11 +1555,6 @@ nd6_prefix_onlink(struct nd_prefix *pr) struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK}; - log(LOG_DEBUG, ##1 nd6_prefix_onlink: %s, vltime = %x, pltime = %x\n, - ip6_sprintf(ip6buf, pr-ndpr_prefix.sin6_addr), - pr-ndpr_vltime, pr-ndpr_pltime); - - /* sanity check */ if ((pr-ndpr_stateflags NDPRF_ONLINK) != 0) { nd6log((LOG_ERR, @@ -1629,11 +1624,6 @@ nd6_prefix_onlink(struct nd_prefix *pr) error = rtrequest(RTM_ADD, (struct sockaddr *)pr-ndpr_prefix, ifa-ifa_addr, (struct sockaddr *)mask6, rtflags, rt); - log(LOG_DEBUG, ##2 nd6_prefix_onlink: %s, vltime = %x, pltime = %x\n, - ip6_sprintf(ip6buf, pr-ndpr_prefix.sin6_addr), - pr-ndpr_vltime, pr-ndpr_pltime); - - if (error == 0) { if (rt != NULL) /* this should be non NULL, though */ { rnh = V_rt_tables[rt-rt_fibnum][AF_INET6]; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r186308 - head/usr.sbin/ppp
Author: qingli Date: Fri Dec 19 01:37:20 2008 New Revision: 186308 URL: http://svn.freebsd.org/changeset/base/186308 Log: The ppp application relies on the if_tun interface to properly install a p2p host route between the end points. The ppp module upates this router based on user configuration later on. The rt_Update() seems to always set the RTF_GATEWAY flag, which is broken. Modified: head/usr.sbin/ppp/route.c Modified: head/usr.sbin/ppp/route.c == --- head/usr.sbin/ppp/route.c Fri Dec 19 00:56:47 2008(r186307) +++ head/usr.sbin/ppp/route.c Fri Dec 19 01:37:20 2008(r186308) @@ -910,8 +910,10 @@ rt_Update(struct bundle *bundle, const s p += memcpy_roundup(p, dst, dst-sa_len); } - rtmes.m_rtm.rtm_addrs |= RTA_GATEWAY; + if (gw != NULL (gw-sa_family != AF_LINK)) +rtmes.m_rtm.rtm_addrs |= RTA_GATEWAY; p += memcpy_roundup(p, gw, gw-sa_len); + if (mask) { rtmes.m_rtm.rtm_addrs |= RTA_NETMASK; p += memcpy_roundup(p, mask, mask-sa_len); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r186317 - head/sys/netinet
Author: qingli Date: Fri Dec 19 11:07:34 2008 New Revision: 186317 URL: http://svn.freebsd.org/changeset/base/186317 Log: The proxy-arp code was broken and responds to ARP requests for addresses that are not proxied locally. Modified: head/sys/netinet/if_ether.c Modified: head/sys/netinet/if_ether.c == --- head/sys/netinet/if_ether.c Fri Dec 19 09:32:31 2008(r186316) +++ head/sys/netinet/if_ether.c Fri Dec 19 11:07:34 2008(r186317) @@ -660,69 +660,64 @@ reply: (void)memcpy(ar_tha(ah), ar_sha(ah), ah-ar_hln); (void)memcpy(ar_sha(ah), enaddr, ah-ar_hln); } else { - if (la == NULL) { - if (!V_arp_proxyall) - goto drop; - - sin.sin_addr = itaddr; - /* XXX MRT use table 0 for arp reply */ - rt = in_rtalloc1((struct sockaddr *)sin, 0, 0UL, 0); - if (!rt) - goto drop; - /* -* Don't send proxies for nodes on the same interface -* as this one came out of, or we'll get into a fight -* over who claims what Ether address. -*/ - if (rt-rt_ifp == ifp) { - RTFREE_LOCKED(rt); - goto drop; - } - (void)memcpy(ar_tha(ah), ar_sha(ah), ah-ar_hln); - (void)memcpy(ar_sha(ah), enaddr, ah-ar_hln); + struct llentry *lle = NULL; + + if (!V_arp_proxyall) + goto drop; + + sin.sin_addr = itaddr; + /* XXX MRT use table 0 for arp reply */ + rt = in_rtalloc1((struct sockaddr *)sin, 0, 0UL, 0); + if (!rt) + goto drop; + + /* +* Don't send proxies for nodes on the same interface +* as this one came out of, or we'll get into a fight +* over who claims what Ether address. +*/ + if (!rt-rt_ifp || rt-rt_ifp == ifp) { RTFREE_LOCKED(rt); + goto drop; + } + IF_AFDATA_LOCK(rt-rt_ifp); + lle = lla_lookup(LLTABLE(rt-rt_ifp), 0, (struct sockaddr *)sin); + IF_AFDATA_UNLOCK(rt-rt_ifp); + RTFREE_LOCKED(rt); - /* -* Also check that the node which sent the ARP packet -* is on the the interface we expect it to be on. This -* avoids ARP chaos if an interface is connected to the -* wrong network. -*/ - sin.sin_addr = isaddr; - - /* XXX MRT use table 0 for arp checks */ - rt = in_rtalloc1((struct sockaddr *)sin, 0, 0UL, 0); - if (!rt) - goto drop; - if (rt-rt_ifp != ifp) { - log(LOG_INFO, arp_proxy: ignoring request -from %s via %s, expecting %s\n, - inet_ntoa(isaddr), ifp-if_xname, - rt-rt_ifp-if_xname); - RTFREE_LOCKED(rt); - goto drop; - } + if (lle != NULL) { + (void)memcpy(ar_tha(ah), ar_sha(ah), ah-ar_hln); + (void)memcpy(ar_sha(ah), lle-ll_addr, ah-ar_hln); + LLE_RUNLOCK(lle); + } else + goto drop; + + /* +* Also check that the node which sent the ARP packet +* is on the the interface we expect it to be on. This +* avoids ARP chaos if an interface is connected to the +* wrong network. +*/ + sin.sin_addr = isaddr; + + /* XXX MRT use table 0 for arp checks */ + rt = in_rtalloc1((struct sockaddr *)sin, 0, 0UL, 0); + if (!rt) + goto drop; + if (rt-rt_ifp != ifp) { + log(LOG_INFO, arp_proxy: ignoring request +from %s via %s, expecting %s\n, + inet_ntoa(isaddr), ifp-if_xname, + rt-rt_ifp-if_xname); RTFREE_LOCKED(rt); + goto drop; + } + RTFREE_LOCKED(rt); #ifdef DEBUG_PROXY - printf(arp: proxying for %s\n, - inet_ntoa(itaddr)); +
svn commit: r186391 - head/sys/net
Author: qingli Date: Mon Dec 22 01:56:56 2008 New Revision: 186391 URL: http://svn.freebsd.org/changeset/base/186391 Log: Provide a condition variable to delay the cloned interface destroy operation until the referenced clone device has been closed by the process properly. The behavior is now consistently with the previous release. Reviewed by:Kip Macy Modified: head/sys/net/if_tun.c Modified: head/sys/net/if_tun.c == --- head/sys/net/if_tun.c Mon Dec 22 00:53:47 2008(r186390) +++ head/sys/net/if_tun.c Mon Dec 22 01:56:56 2008(r186391) @@ -57,6 +57,7 @@ #include net/if_tun.h #include sys/queue.h +#include sys/condvar.h #include security/mac/mac_framework.h @@ -93,6 +94,7 @@ struct tun_softc { struct sigio *tun_sigio; /* information for async I/O */ struct selinfo tun_rsel; /* read select */ struct mtx tun_mtx;/* protect mutable softc fields */ + struct cv tun_cv; /* protect against ref'd dev destroy */ }; #define TUN2IFP(sc)((sc)-tun_ifp) @@ -253,8 +255,9 @@ tun_destroy(struct tun_softc *tp) struct cdev *dev; /* Unlocked read. */ - KASSERT((tp-tun_flags TUN_OPEN) == 0, - (tununits is out of sync - unit %d, TUN2IFP(tp)-if_dunit)); + mtx_lock(tp-tun_mtx); + if ((tp-tun_flags TUN_OPEN) != 0) + cv_wait_unlock(tp-tun_cv, tp-tun_mtx); CURVNET_SET(TUN2IFP(tp)-if_vnet); dev = tp-tun_dev; @@ -264,6 +267,7 @@ tun_destroy(struct tun_softc *tp) destroy_dev(dev); knlist_destroy(tp-tun_rsel.si_note); mtx_destroy(tp-tun_mtx); + cv_destroy(tp-tun_cv); free(tp, M_TUN); CURVNET_RESTORE(); } @@ -365,6 +369,7 @@ tuncreate(const char *name, struct cdev sc = malloc(sizeof(*sc), M_TUN, M_WAITOK | M_ZERO); mtx_init(sc-tun_mtx, tun_mtx, NULL, MTX_DEF); + cv_init(sc-tun_cv, tun_condvar); sc-tun_flags = TUN_INITED; sc-tun_dev = dev; mtx_lock(tunmtx); @@ -449,6 +454,7 @@ tunclose(struct cdev *dev, int foo, int mtx_lock(tp-tun_mtx); tp-tun_flags = ~TUN_OPEN; tp-tun_pid = 0; + mtx_unlock(tp-tun_mtx); /* * junk all pending output @@ -457,7 +463,6 @@ tunclose(struct cdev *dev, int foo, int s = splimp(); IFQ_PURGE(ifp-if_snd); splx(s); - mtx_unlock(tp-tun_mtx); if (ifp-if_flags IFF_UP) { s = splimp(); @@ -486,10 +491,14 @@ tunclose(struct cdev *dev, int foo, int if_link_state_change(ifp, LINK_STATE_DOWN); CURVNET_RESTORE(); + mtx_lock(tp-tun_mtx); funsetown(tp-tun_sigio); selwakeuppri(tp-tun_rsel, PZERO + 1); KNOTE_UNLOCKED(tp-tun_rsel.si_note, 0); TUNDEBUG (ifp, closed\n); + + cv_broadcast(tp-tun_cv); + mtx_unlock(tp-tun_mtx); return (0); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r186392 - head/sys/netinet6
Author: qingli Date: Mon Dec 22 07:11:15 2008 New Revision: 186392 URL: http://svn.freebsd.org/changeset/base/186392 Log: Similar to the INET case, do not destroy the nd6 entries for interface addresses until those addresses are removed. I already made the patch in INET but forgot to bring the code over for INET6. Modified: head/sys/netinet6/in6.c Modified: head/sys/netinet6/in6.c == --- head/sys/netinet6/in6.c Mon Dec 22 01:56:56 2008(r186391) +++ head/sys/netinet6/in6.c Mon Dec 22 07:11:15 2008(r186392) @@ -2204,12 +2204,14 @@ in6_lltable_lookup(struct lltable *llt, lle-lle_head = lleh; LIST_INSERT_HEAD(lleh, lle, lle_next); } else if (flags LLE_DELETE) { - LLE_WLOCK(lle); - lle-la_flags = LLE_DELETED; - LLE_WUNLOCK(lle); + if (!(lle-la_flags LLE_IFADDR) || (flags LLE_IFADDR)) { + LLE_WLOCK(lle); + lle-la_flags = LLE_DELETED; + LLE_WUNLOCK(lle); #ifdef DIAGNOSTICS - log(LOG_INFO, ifaddr cache = %p is deleted\n, lle); + log(LOG_INFO, ifaddr cache = %p is deleted\n, lle); #endif + } lle = (void *)-1; } if (LLE_IS_VALID(lle)) { ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r186411 - head/sys/netinet
Author: qingli Date: Tue Dec 23 03:33:32 2008 New Revision: 186411 URL: http://svn.freebsd.org/changeset/base/186411 Log: Don't create a bogus ARP entry for 0.0.0.0. Modified: head/sys/netinet/if_ether.c Modified: head/sys/netinet/if_ether.c == --- head/sys/netinet/if_ether.c Tue Dec 23 02:19:14 2008(r186410) +++ head/sys/netinet/if_ether.c Tue Dec 23 03:33:32 2008(r186411) @@ -758,23 +758,24 @@ arp_ifinit(struct ifnet *ifp, struct ifa { struct llentry *lle; - if (ntohl(IA_SIN(ifa)-sin_addr.s_addr) != INADDR_ANY) + if (ntohl(IA_SIN(ifa)-sin_addr.s_addr) != INADDR_ANY) { arprequest(ifp, IA_SIN(ifa)-sin_addr, IA_SIN(ifa)-sin_addr, IF_LLADDR(ifp)); - /* -* interface address is considered static entry -* because the output of the arp utility shows -* that L2 entry as permanent -*/ - IF_AFDATA_LOCK(ifp); - lle = lla_lookup(LLTABLE(ifp), (LLE_CREATE | LLE_IFADDR | LLE_STATIC), - (struct sockaddr *)IA_SIN(ifa)); - IF_AFDATA_UNLOCK(ifp); - if (lle == NULL) - log(LOG_INFO, arp_ifinit: cannot create arp - entry for interface address\n); - else - LLE_RUNLOCK(lle); + /* +* interface address is considered static entry +* because the output of the arp utility shows +* that L2 entry as permanent +*/ + IF_AFDATA_LOCK(ifp); + lle = lla_lookup(LLTABLE(ifp), (LLE_CREATE | LLE_IFADDR | LLE_STATIC), +(struct sockaddr *)IA_SIN(ifa)); + IF_AFDATA_UNLOCK(ifp); + if (lle == NULL) + log(LOG_INFO, arp_ifinit: cannot create arp + entry for interface address\n); + else + LLE_RUNLOCK(lle); + } ifa-ifa_rtrequest = NULL; } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org