Module Name: src
Committed By: zoltan
Date: Sat Nov 5 10:23:26 UTC 2011
Modified Files:
src/sys/net/npf: npf_handler.c npf_sendpkt.c
Log Message:
When building the kernel without IPv6 support, compilation failed.
Fix that.
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/net/npf/npf_handler.c
cvs rdiff -u -r1.5 -r1.6 src/sys/net/npf/npf_sendpkt.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/net/npf/npf_handler.c
diff -u src/sys/net/npf/npf_handler.c:1.8 src/sys/net/npf/npf_handler.c:1.9
--- src/sys/net/npf/npf_handler.c:1.8 Fri Nov 4 01:00:27 2011
+++ src/sys/net/npf/npf_handler.c Sat Nov 5 10:23:26 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_handler.c,v 1.8 2011/11/04 01:00:27 zoltan Exp $ */
+/* $NetBSD: npf_handler.c,v 1.9 2011/11/05 10:23:26 zoltan Exp $ */
/*-
* Copyright (c) 2009-2010 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_handler.c,v 1.8 2011/11/04 01:00:27 zoltan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_handler.c,v 1.9 2011/11/05 10:23:26 zoltan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -110,14 +110,17 @@ npf_packet_handler(void *arg, struct mbu
struct ip *ip = nbuf_dataptr(*mp);
/* Pass to IPv4 reassembly mechanism. */
ret = ip_reass_packet(mp, ip);
- } else if (npf_iscached(&npc, NPC_IP6)) {
+ } else {
+ KASSERT(npf_iscached(&npc, NPC_IP6));
+#ifdef INET6
/* frag6_input's offset is the start of the fragment header */
size_t hlen = npf_cache_hlen(&npc, nbuf);
/* Pass to IPv6 reassembly mechanism. */
ret = ip6_reass_packet(mp, hlen);
- } else {
+#else
KASSERT(false);
+#endif
}
if (ret != 0) {
Index: src/sys/net/npf/npf_sendpkt.c
diff -u src/sys/net/npf/npf_sendpkt.c:1.5 src/sys/net/npf/npf_sendpkt.c:1.6
--- src/sys/net/npf/npf_sendpkt.c:1.5 Fri Nov 4 01:00:27 2011
+++ src/sys/net/npf/npf_sendpkt.c Sat Nov 5 10:23:26 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_sendpkt.c,v 1.5 2011/11/04 01:00:27 zoltan Exp $ */
+/* $NetBSD: npf_sendpkt.c,v 1.6 2011/11/05 10:23:26 zoltan Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_sendpkt.c,v 1.5 2011/11/04 01:00:27 zoltan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_sendpkt.c,v 1.6 2011/11/05 10:23:26 zoltan Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -79,10 +79,12 @@ npf_return_tcp(npf_cache_t *npc, nbuf_t
}
/* Create and setup a network buffer. */
- if (npc->npc_info & NPC_IP4)
+ if (npf_iscached(npc, NPC_IP4))
len = sizeof(struct ip) + sizeof(struct tcphdr);
- else
+ else {
+ KASSERT(npf_iscached(npc, NPC_IP6));
len = sizeof(struct ip6_hdr) + sizeof(struct tcphdr);
+ }
m = m_gethdr(M_DONTWAIT, MT_HEADER);
if (m == NULL) {
@@ -92,7 +94,7 @@ npf_return_tcp(npf_cache_t *npc, nbuf_t
m->m_len = len;
m->m_pkthdr.len = len;
- if (npc->npc_info & NPC_IP4) {
+ if (npf_iscached(npc, NPC_IP4)) {
struct ip *oip = &npc->npc_ip.v4;
ip = mtod(m, struct ip *);
memset(ip, 0, len);
@@ -108,6 +110,7 @@ npf_return_tcp(npf_cache_t *npc, nbuf_t
th = (struct tcphdr *)(ip + 1);
} else {
+ KASSERT(npf_iscached(npc, NPC_IP6));
struct ip6_hdr *oip = &npc->npc_ip.v6;
ip6 = mtod(m, struct ip6_hdr *);
memset(ip6, 0, len);
@@ -133,7 +136,7 @@ npf_return_tcp(npf_cache_t *npc, nbuf_t
th->th_off = sizeof(struct tcphdr) >> 2;
th->th_flags = TH_ACK | TH_RST;
- if (npc->npc_info & NPC_IP4) {
+ if (npf_iscached(npc, NPC_IP4)) {
th->th_sum = in_cksum(m, len);
/* Second fill of IPv4 header, fill correct IP length. */
@@ -143,14 +146,24 @@ npf_return_tcp(npf_cache_t *npc, nbuf_t
ip->ip_len = htons(len);
ip->ip_ttl = DEFAULT_IP_TTL;
} else {
+ KASSERT(npf_iscached(npc, NPC_IP6));
+#ifdef INET6
th->th_sum = in6_cksum(m, IPPROTO_TCP, sizeof(struct ip6_hdr), sizeof(struct tcphdr));
+#else
+ KASSERT(false);
+#endif
}
/* Pass to IP layer. */
if (npc->npc_info & NPC_IP4) {
return ip_output(m, NULL, NULL, IP_FORWARDING, NULL, NULL);
} else {
+#ifdef INET6
return ip6_output(m, NULL, NULL, IPV6_FORWARDING, NULL, NULL, NULL);
+#else
+ KASSERT(false);
+ return 0;
+#endif
}
}
@@ -166,7 +179,11 @@ npf_return_icmp(npf_cache_t *npc, nbuf_t
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_ADMIN_PROHIBIT, 0, 0);
} else {
KASSERT(npf_iscached(npc, NPC_IP6));
+#ifdef INET6
icmp6_error(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADMIN, 0);
+#else
+ KASSERT(false);
+#endif
}
return 0;
}