aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorBjoern A. Zeeb <bz@FreeBSD.org>2011-04-27 19:30:44 +0000
committerBjoern A. Zeeb <bz@FreeBSD.org>2011-04-27 19:30:44 +0000
commita0ae8f04e881e0b9b9344374329b60aa0c6ae106 (patch)
tree41ab0d5e24ff61a4333e89667bf72cddb5e47b41 /sys
parentdb178eb816e2aca4268deb94031d3dcf6e021d8a (diff)
downloadsrc-a0ae8f04e881e0b9b9344374329b60aa0c6ae106.tar.gz
src-a0ae8f04e881e0b9b9344374329b60aa0c6ae106.zip
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
Notes
Notes: svn path=/head/; revision=221130
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/xen/netfront/netfront.c12
-rw-r--r--sys/net/if_enc.c18
-rw-r--r--sys/net/if_lagg.c4
-rw-r--r--sys/netinet/ip_carp.c53
4 files changed, 73 insertions, 14 deletions
diff --git a/sys/dev/xen/netfront/netfront.c b/sys/dev/xen/netfront/netfront.c
index e47c3cc49590..40ff031121c3 100644
--- a/sys/dev/xen/netfront/netfront.c
+++ b/sys/dev/xen/netfront/netfront.c
@@ -28,6 +28,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "opt_inet.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sockio.h>
@@ -625,6 +627,7 @@ setup_device(device_t dev, struct netfront_info *info)
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, struct netfront_info *info)
}
}
}
+#endif
/**
* Callback received when the backend's state changes.
@@ -668,7 +672,9 @@ netfront_backend_changed(device_t dev, XenbusState newstate)
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, caddr_t data)
{
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, caddr_t data)
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 ?*/
diff --git a/sys/net/if_enc.c b/sys/net/if_enc.c
index 6ba117441f41..eee373396456 100644
--- a/sys/net/if_enc.c
+++ b/sys/net/if_enc.c
@@ -27,6 +27,10 @@
* $FreeBSD$
*/
+#include "opt_inet.h"
+#include "opt_inet6.h"
+#include "opt_enc.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@@ -53,14 +57,12 @@
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/in_var.h>
-#include "opt_inet6.h"
#ifdef INET6
#include <netinet/ip6.h>
#include <netinet6/ip6_var.h>
#endif
-#include "opt_enc.h"
#include <netipsec/ipsec.h>
#include <netipsec/xform.h>
@@ -243,11 +245,14 @@ ipsec_filter(struct mbuf **mp, int dir, int flags)
}
/* 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, int flags)
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, int flags)
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,
diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c
index ee586ad155cb..cbe9b9990b56 100644
--- a/sys/net/if_lagg.c
+++ b/sys/net/if_lagg.c
@@ -52,8 +52,10 @@ __FBSDID("$FreeBSD$");
#include <net/if_var.h>
#include <net/bpf.h>
-#ifdef INET
+#if defined(INET) || defined(INET6)
#include <netinet/in.h>
+#endif
+#ifdef INET
#include <netinet/in_systm.h>
#include <netinet/if_ether.h>
#include <netinet/ip.h>
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index 1354d5e7c5cf..d16159d7d369 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -66,14 +66,19 @@ __FBSDID("$FreeBSD$");
#include <net/route.h>
#include <net/vnet.h>
-#ifdef INET
+#if defined(INET) || defined(INET6)
#include <netinet/in.h>
#include <netinet/in_var.h>
-#include <netinet/in_systm.h>
+#include <netinet/ip_carp.h>
#include <netinet/ip.h>
+
+#include <machine/in_cksum.h>
+#endif
+
+#ifdef INET
+#include <netinet/in_systm.h>
#include <netinet/ip_var.h>
#include <netinet/if_ether.h>
-#include <machine/in_cksum.h>
#endif
#ifdef INET6
@@ -82,11 +87,11 @@ __FBSDID("$FreeBSD$");
#include <netinet6/ip6protosw.h>
#include <netinet6/ip6_var.h>
#include <netinet6/scope6_var.h>
+#include <netinet6/in6_var.h>
#include <netinet6/nd6.h>
#endif
#include <crypto/sha1.h>
-#include <netinet/ip_carp.h>
#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 *, struct carp_softc *,
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 *, struct mbuf *, struct sockaddr *,
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 cmd)
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)
(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, int unit, caddr_t params)
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 unlock)
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 ifnet *ifp)
* 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_header *ch, sa_family_t af)
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 *sc)
}
+#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 in_ifaddr *ia,
CARP_UNLOCK(cif);
return (0);
}
+#endif
#ifdef INET6
struct ifaddr *
@@ -1353,7 +1384,9 @@ carp_master_down_locked(struct carp_softc *sc)
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_family_t af)
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_family_t af)
}
}
+#ifdef INET
static void
carp_multicast_cleanup(struct carp_softc *sc, int dofree)
{
@@ -1463,6 +1499,7 @@ carp_multicast_cleanup(struct carp_softc *sc, int dofree)
imo->imo_num_memberships = 0;
imo->imo_multicast_ifp = NULL;
}
+#endif
#ifdef INET6
static void
@@ -1485,6 +1522,7 @@ carp_multicast6_cleanup(struct carp_softc *sc, int dofree)
}
#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, struct sockaddr_in *sin)
return (error);
}
+#endif
#ifdef INET6
static int