From owner-svn-src-all@FreeBSD.ORG Wed Apr 27 19:30:45 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 410DA1065670; Wed, 27 Apr 2011 19:30:45 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 27A5C8FC0A; Wed, 27 Apr 2011 19:30:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p3RJUjBf085847; Wed, 27 Apr 2011 19:30:45 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p3RJUi1r085842; Wed, 27 Apr 2011 19:30:44 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201104271930.p3RJUi1r085842@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Wed, 27 Apr 2011 19:30:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r221130 - in head/sys: dev/xen/netfront net netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Apr 2011 19:30:45 -0000 Author: bz Date: Wed Apr 27 19:30:44 2011 New Revision: 221130 URL: http://svn.freebsd.org/changeset/base/221130 Log: Make various (pseudo) interfaces compile without INET in the kernel adding appropriate #ifdefs. For module builds the framework needs adjustments for at least carp. Reviewed by: gnn Sponsored by: The FreeBSD Foundation Sponsored by: iXsystems MFC after: 4 days Modified: head/sys/dev/xen/netfront/netfront.c head/sys/net/if_enc.c head/sys/net/if_lagg.c head/sys/netinet/ip_carp.c Modified: head/sys/dev/xen/netfront/netfront.c ============================================================================== --- head/sys/dev/xen/netfront/netfront.c Wed Apr 27 19:28:42 2011 (r221129) +++ head/sys/dev/xen/netfront/netfront.c Wed Apr 27 19:30:44 2011 (r221130) @@ -28,6 +28,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_inet.h" + #include #include #include @@ -625,6 +627,7 @@ setup_device(device_t dev, struct netfro return (error); } +#ifdef INET /** * If this interface has an ipv4 address, send an arp for it. This * helps to get the network going again after migrating hosts. @@ -642,6 +645,7 @@ netfront_send_fake_arp(device_t dev, str } } } +#endif /** * Callback received when the backend's state changes. @@ -668,7 +672,9 @@ netfront_backend_changed(device_t dev, X if (network_connect(sc) != 0) break; xenbus_set_state(dev, XenbusStateConnected); +#ifdef INET netfront_send_fake_arp(dev, sc); +#endif break; case XenbusStateClosing: xenbus_set_state(dev, XenbusStateClosed); @@ -1725,12 +1731,15 @@ xn_ioctl(struct ifnet *ifp, u_long cmd, { struct netfront_info *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *) data; +#ifdef INET struct ifaddr *ifa = (struct ifaddr *)data; +#endif int mask, error = 0; switch(cmd) { case SIOCSIFADDR: case SIOCGIFADDR: +#ifdef INET XN_LOCK(sc); if (ifa->ifa_addr->sa_family == AF_INET) { ifp->if_flags |= IFF_UP; @@ -1740,8 +1749,11 @@ xn_ioctl(struct ifnet *ifp, u_long cmd, XN_UNLOCK(sc); } else { XN_UNLOCK(sc); +#endif error = ether_ioctl(ifp, cmd, data); +#ifdef INET } +#endif break; case SIOCSIFMTU: /* XXX can we alter the MTU on a VN ?*/ Modified: head/sys/net/if_enc.c ============================================================================== --- head/sys/net/if_enc.c Wed Apr 27 19:28:42 2011 (r221129) +++ head/sys/net/if_enc.c Wed Apr 27 19:30:44 2011 (r221130) @@ -27,6 +27,10 @@ * $FreeBSD$ */ +#include "opt_inet.h" +#include "opt_inet6.h" +#include "opt_enc.h" + #include #include #include @@ -53,14 +57,12 @@ #include #include #include -#include "opt_inet6.h" #ifdef INET6 #include #include #endif -#include "opt_enc.h" #include #include @@ -243,11 +245,14 @@ ipsec_filter(struct mbuf **mp, int dir, } /* Skip pfil(9) if no filters are loaded */ - if (!(PFIL_HOOKED(&V_inet_pfil_hook) + if (1 +#ifdef INET + && !PFIL_HOOKED(&V_inet_pfil_hook) +#endif #ifdef INET6 - || PFIL_HOOKED(&V_inet6_pfil_hook) + && !PFIL_HOOKED(&V_inet6_pfil_hook) #endif - )) { + ) { return (0); } @@ -263,6 +268,7 @@ ipsec_filter(struct mbuf **mp, int dir, error = 0; ip = mtod(*mp, struct ip *); switch (ip->ip_v) { +#ifdef INET case 4: /* * before calling the firewall, swap fields the same as @@ -282,7 +288,7 @@ ipsec_filter(struct mbuf **mp, int dir, ip->ip_len = htons(ip->ip_len); ip->ip_off = htons(ip->ip_off); break; - +#endif #ifdef INET6 case 6: error = pfil_run_hooks(&V_inet6_pfil_hook, mp, Modified: head/sys/net/if_lagg.c ============================================================================== --- head/sys/net/if_lagg.c Wed Apr 27 19:28:42 2011 (r221129) +++ head/sys/net/if_lagg.c Wed Apr 27 19:30:44 2011 (r221130) @@ -52,8 +52,10 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef INET +#if defined(INET) || defined(INET6) #include +#endif +#ifdef INET #include #include #include Modified: head/sys/netinet/ip_carp.c ============================================================================== --- head/sys/netinet/ip_carp.c Wed Apr 27 19:28:42 2011 (r221129) +++ head/sys/netinet/ip_carp.c Wed Apr 27 19:30:44 2011 (r221130) @@ -66,14 +66,19 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef INET +#if defined(INET) || defined(INET6) #include #include -#include +#include #include + +#include +#endif + +#ifdef INET +#include #include #include -#include #endif #ifdef INET6 @@ -82,11 +87,11 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #endif #include -#include #define CARP_IFNAME "carp" static MALLOC_DEFINE(M_CARP, "CARP", "CARP interfaces"); @@ -96,7 +101,9 @@ struct carp_softc { struct ifnet *sc_ifp; /* Interface clue */ struct ifnet *sc_carpdev; /* Pointer to parent interface */ struct in_ifaddr *sc_ia; /* primary iface address */ +#ifdef INET struct ip_moptions sc_imo; +#endif #ifdef INET6 struct in6_ifaddr *sc_ia6; /* primary iface address v6 */ struct ip6_moptions sc_im6o; @@ -206,7 +213,9 @@ static int carp_prepare_ad(struct mbuf * static void carp_send_ad_all(void); static void carp_send_ad(void *); static void carp_send_ad_locked(struct carp_softc *); +#ifdef INET static void carp_send_arp(struct carp_softc *); +#endif static void carp_master_down(void *); static void carp_master_down_locked(struct carp_softc *); static int carp_ioctl(struct ifnet *, u_long, caddr_t); @@ -215,12 +224,16 @@ static int carp_looutput(struct ifnet *, static void carp_start(struct ifnet *); static void carp_setrun(struct carp_softc *, sa_family_t); static void carp_set_state(struct carp_softc *, int); +#ifdef INET static int carp_addrcount(struct carp_if *, struct in_ifaddr *, int); +#endif enum { CARP_COUNT_MASTER, CARP_COUNT_RUNNING }; +#ifdef INET static void carp_multicast_cleanup(struct carp_softc *, int dofree); static int carp_set_addr(struct carp_softc *, struct sockaddr_in *); static int carp_del_addr(struct carp_softc *, struct sockaddr_in *); +#endif static void carp_carpdev_state_locked(struct carp_if *); static void carp_sc_state_locked(struct carp_softc *); #ifdef INET6 @@ -369,6 +382,7 @@ carp_setroute(struct carp_softc *sc, int s = splnet(); TAILQ_FOREACH(ifa, &SC2IFP(sc)->if_addrlist, ifa_list) { +#ifdef INET if (ifa->ifa_addr->sa_family == AF_INET && sc->sc_carpdev != NULL) { int count = carp_addrcount( @@ -379,6 +393,7 @@ carp_setroute(struct carp_softc *sc, int (cmd == RTM_DELETE && count == 0)) rtinit(ifa, cmd, RTF_UP | RTF_HOST); } +#endif } splx(s); } @@ -404,12 +419,14 @@ carp_clone_create(struct if_clone *ifc, sc->sc_advskew = 0; sc->sc_init_counter = 1; sc->sc_naddrs = sc->sc_naddrs6 = 0; /* M_ZERO? */ +#ifdef INET sc->sc_imo.imo_membership = (struct in_multi **)malloc( (sizeof(struct in_multi *) * IP_MIN_MEMBERSHIPS), M_CARP, M_WAITOK); sc->sc_imo.imo_mfilters = NULL; sc->sc_imo.imo_max_memberships = IP_MIN_MEMBERSHIPS; sc->sc_imo.imo_multicast_vif = -1; +#endif #ifdef INET6 sc->sc_im6o.im6o_membership = (struct in6_multi **)malloc( (sizeof(struct in6_multi *) * IPV6_MIN_MEMBERSHIPS), M_CARP, @@ -456,7 +473,9 @@ carp_clone_destroy(struct ifnet *ifp) bpfdetach(ifp); if_detach(ifp); if_free_type(ifp, IFT_ETHER); +#ifdef INET free(sc->sc_imo.imo_membership, M_CARP); +#endif #ifdef INET6 free(sc->sc_im6o.im6o_membership, M_CARP); #endif @@ -495,7 +514,9 @@ carpdetach(struct carp_softc *sc, int un carp_set_state(sc, INIT); SC2IFP(sc)->if_flags &= ~IFF_UP; carp_setrun(sc, 0); +#ifdef INET carp_multicast_cleanup(sc, unlock); +#endif #ifdef INET6 carp_multicast6_cleanup(sc, unlock); #endif @@ -540,6 +561,7 @@ carp_ifdetach(void *arg __unused, struct * we have rearranged checks order compared to the rfc, * but it seems more efficient this way or not possible otherwise. */ +#ifdef INET void carp_input(struct mbuf *m, int hlen) { @@ -630,6 +652,7 @@ carp_input(struct mbuf *m, int hlen) carp_input_c(m, ch, AF_INET); } +#endif #ifdef INET6 int @@ -720,12 +743,16 @@ carp_input_c(struct mbuf *m, struct carp SC2IFP(sc)->if_ibytes += m->m_pkthdr.len; if (bpf_peers_present(SC2IFP(sc)->if_bpf)) { - struct ip *ip = mtod(m, struct ip *); uint32_t af1 = af; +#ifdef INET + struct ip *ip = mtod(m, struct ip *); /* BPF wants net byte order */ - ip->ip_len = htons(ip->ip_len + (ip->ip_hl << 2)); - ip->ip_off = htons(ip->ip_off); + if (af == AF_INET) { + ip->ip_len = htons(ip->ip_len + (ip->ip_hl << 2)); + ip->ip_off = htons(ip->ip_off); + } +#endif bpf_mtap2(SC2IFP(sc)->if_bpf, &af1, sizeof(af1), m); } @@ -1081,6 +1108,7 @@ carp_send_ad_locked(struct carp_softc *s } +#ifdef INET /* * Broadcast a gratuitous ARP request containing * the virtual router MAC address for each IP address @@ -1102,6 +1130,7 @@ carp_send_arp(struct carp_softc *sc) DELAY(1000); /* XXX */ } } +#endif #ifdef INET6 static void @@ -1124,6 +1153,7 @@ carp_send_na(struct carp_softc *sc) } #endif /* INET6 */ +#ifdef INET static int carp_addrcount(struct carp_if *cif, struct in_ifaddr *ia, int type) { @@ -1227,6 +1257,7 @@ carp_iamatch(struct ifnet *ifp, struct i CARP_UNLOCK(cif); return (0); } +#endif #ifdef INET6 struct ifaddr * @@ -1353,7 +1384,9 @@ carp_master_down_locked(struct carp_soft case BACKUP: carp_set_state(sc, MASTER); carp_send_ad_locked(sc); +#ifdef INET carp_send_arp(sc); +#endif #ifdef INET6 carp_send_na(sc); #endif /* INET6 */ @@ -1393,7 +1426,9 @@ carp_setrun(struct carp_softc *sc, sa_fa case INIT: if (carp_opts[CARPCTL_PREEMPT] && !carp_suppress_preempt) { carp_send_ad_locked(sc); +#ifdef INET carp_send_arp(sc); +#endif #ifdef INET6 carp_send_na(sc); #endif /* INET6 */ @@ -1444,6 +1479,7 @@ carp_setrun(struct carp_softc *sc, sa_fa } } +#ifdef INET static void carp_multicast_cleanup(struct carp_softc *sc, int dofree) { @@ -1463,6 +1499,7 @@ carp_multicast_cleanup(struct carp_softc imo->imo_num_memberships = 0; imo->imo_multicast_ifp = NULL; } +#endif #ifdef INET6 static void @@ -1485,6 +1522,7 @@ carp_multicast6_cleanup(struct carp_soft } #endif +#ifdef INET static int carp_set_addr(struct carp_softc *sc, struct sockaddr_in *sin) { @@ -1661,6 +1699,7 @@ carp_del_addr(struct carp_softc *sc, str return (error); } +#endif #ifdef INET6 static int