Date: Tue, 4 Nov 2014 18:48:13 +0000 (UTC) From: "Alexander V. Chernikov" <melifaro@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r274098 - in projects/routing/sys: net netinet netinet6 Message-ID: <201411041848.sA4ImDG0038682@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: melifaro Date: Tue Nov 4 18:48:13 2014 New Revision: 274098 URL: https://svnweb.freebsd.org/changeset/base/274098 Log: Convert gif and stf to use new routing api. Modified: projects/routing/sys/net/if_stf.c projects/routing/sys/netinet/in_gif.c projects/routing/sys/netinet6/in6_gif.c Modified: projects/routing/sys/net/if_stf.c ============================================================================== --- projects/routing/sys/net/if_stf.c Tue Nov 4 18:22:33 2014 (r274097) +++ projects/routing/sys/net/if_stf.c Tue Nov 4 18:48:13 2014 (r274098) @@ -116,6 +116,8 @@ #include <netinet/ip_encap.h> +#include <net/rt_nhops.h> + #include <machine/stdarg.h> #include <net/bpf.h> @@ -572,26 +574,12 @@ stf_checkaddr4(sc, in, inifp) * perform ingress filter */ if (sc && (STF2IFP(sc)->if_flags & IFF_LINK2) == 0 && inifp) { - struct sockaddr_in sin; - struct rtentry *rt; + struct nhop4_basic nh4; - bzero(&sin, sizeof(sin)); - sin.sin_family = AF_INET; - sin.sin_len = sizeof(struct sockaddr_in); - sin.sin_addr = *in; - rt = rtalloc1_fib((struct sockaddr *)&sin, 0, - 0UL, sc->sc_fibnum); - if (!rt || rt->rt_ifp != inifp) { -#if 0 - log(LOG_WARNING, "%s: packet from 0x%x dropped " - "due to ingress filter\n", if_name(STF2IFP(sc)), - (u_int32_t)ntohl(sin.sin_addr.s_addr)); -#endif - if (rt) - RTFREE_LOCKED(rt); - return -1; - } - RTFREE_LOCKED(rt); + if (fib4_lookup_nh_basic(sc->sc_fibnum, *in, 0, &nh4) != 0) + return (-1); + if (nh4.nh_ifp != inifp) + return (-1); } return 0; Modified: projects/routing/sys/netinet/in_gif.c ============================================================================== --- projects/routing/sys/netinet/in_gif.c Tue Nov 4 18:22:33 2014 (r274097) +++ projects/routing/sys/netinet/in_gif.c Tue Nov 4 18:48:13 2014 (r274098) @@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$"); #include <net/if.h> #include <net/if_var.h> #include <net/route.h> -#include <net/route_internal.h> #include <net/vnet.h> #include <netinet/in.h> @@ -68,6 +67,7 @@ __FBSDID("$FreeBSD$"); #endif #include <net/if_gif.h> +#include <net/rt_nhops.h> static int gif_validate4(const struct ip *, struct gif_softc *, struct ifnet *); @@ -188,22 +188,15 @@ gif_validate4(const struct ip *ip, struc /* ingress filters on outer source */ if ((GIF2IFP(sc)->if_flags & IFF_LINK2) == 0 && ifp) { - struct sockaddr_in sin; - struct rtentry *rt; + struct nhop4_basic nh4; + uint32_t fibnum; - bzero(&sin, sizeof(sin)); - sin.sin_family = AF_INET; - sin.sin_len = sizeof(struct sockaddr_in); - sin.sin_addr = ip->ip_src; - /* XXX MRT check for the interface we would use on output */ - rt = in_rtalloc1((struct sockaddr *)&sin, 0, - 0UL, sc->gif_fibnum); - if (!rt || rt->rt_ifp != ifp) { - if (rt) - RTFREE_LOCKED(rt); + fibnum = sc->gif_fibnum; + + if (fib4_lookup_nh_basic(fibnum, ip->ip_src, 0, &nh4) != 0) + return (0); + if (nh4.nh_ifp != ifp) return (0); - } - RTFREE_LOCKED(rt); } return (32 * 2); } Modified: projects/routing/sys/netinet6/in6_gif.c ============================================================================== --- projects/routing/sys/netinet6/in6_gif.c Tue Nov 4 18:22:33 2014 (r274097) +++ projects/routing/sys/netinet6/in6_gif.c Tue Nov 4 18:48:13 2014 (r274098) @@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$"); #include <net/if.h> #include <net/if_var.h> #include <net/route.h> -#include <net/route_internal.h> #include <net/vnet.h> #include <netinet/in.h> @@ -67,6 +66,7 @@ __FBSDID("$FreeBSD$"); #include <netinet6/ip6_var.h> #include <netinet6/in6_gif.h> #include <netinet6/in6_var.h> +#include <netinet6/scope6_var.h> #endif #include <netinet/ip_ecn.h> #ifdef INET6 @@ -74,6 +74,7 @@ __FBSDID("$FreeBSD$"); #endif #include <net/if_gif.h> +#include <net/rt_nhops.h> VNET_DEFINE(int, ip6_gif_hlim) = GIF_HLIM; #define V_ip6_gif_hlim VNET(ip6_gif_hlim) @@ -195,23 +196,17 @@ gif_validate6(const struct ip6_hdr *ip6, /* ingress filters on outer source */ if ((GIF2IFP(sc)->if_flags & IFF_LINK2) == 0 && ifp) { - struct sockaddr_in6 sin6; - struct rtentry *rt; + struct nhop6_basic nh6; + struct in6_addr src; + uint32_t fibnum, scopeid; - bzero(&sin6, sizeof(sin6)); - sin6.sin6_family = AF_INET6; - sin6.sin6_len = sizeof(struct sockaddr_in6); - sin6.sin6_addr = ip6->ip6_src; - sin6.sin6_scope_id = 0; /* XXX */ - - rt = in6_rtalloc1((struct sockaddr *)&sin6, 0, 0UL, - sc->gif_fibnum); - if (!rt || rt->rt_ifp != ifp) { - if (rt) - RTFREE_LOCKED(rt); + fibnum = sc->gif_fibnum; + in6_splitscope(&ip6->ip6_src, &src, &scopeid); + + if (fib6_lookup_nh_basic(fibnum, &src, scopeid, 0, &nh6) != 0) + return (0); + if (nh6.nh_ifp != ifp) return (0); - } - RTFREE_LOCKED(rt); } return (128 * 2);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201411041848.sA4ImDG0038682>