kern/52764: Impossible to build kernel with COPTFLAGS=-O0 and
without INET6
Artem 'Zazoobr' Ignatjev
timon at memphis.mephi.ru
Mon Jun 2 02:26:22 PDT 2003
Yar Tikhiy wrote:
> >How-To-Repeat:
> Add "makeoptions COPTFLAGS=-O0" to a kernel configuration file
> and make sure there is no "options INET6" in it. Try to build
> such a kernel. Observe the following linker diagnostics:
>
> linking kernel.debug
> tcp_input.o: In function `tcp_input':
> ../../../netinet/tcp_input.c:400: undefined reference to `in6_cksum'
> ../../../netinet/tcp_input.c:480: undefined reference to `ip6stat'
> ../../../netinet/tcp_input.c:480: undefined reference to `ip6stat'
> ../../../netinet/tcp_input.c:480: undefined reference to `ip6stat'
> ../../../netinet/tcp_input.c:480: undefined reference to `ip6stat'
> ../../../netinet/tcp_input.c:480: undefined reference to `ip6stat'
...
Hello.
I came across this problem yesterday..
As a workaround you can use following patch:
--- sys/netinet/tcp_input.c.orig Sun Jun 1 22:23:58 2003
+++ sys/netinet/tcp_input.c Sun Jun 1 23:03:27 2003
@@ -396,6 +396,7 @@
if (isipv6) {
/* IP6_EXTHDR_CHECK() is already done at tcp6_input() */
ip6 = mtod(m, struct ip6_hdr *);
+#ifdef INET6
tlen = sizeof(*ip6) + ntohs(ip6->ip6_plen) - off0;
if (in6_cksum(m, IPPROTO_TCP, off0, tlen)) {
tcpstat.tcps_rcvbadsum++;
@@ -415,6 +416,12 @@
/* XXX stat */
goto drop;
}
+#else
+ /*
+ * XXX otherwise compiler complains about th being used uninitialized
+ */
+ th = (struct tcphdr *)((caddr_t)ip6 + off0);
+#endif
} else {
/*
* Get IP and TCP header together in first mbuf.
@@ -476,10 +483,13 @@
}
tlen -= off; /* tlen is used instead of ti->ti_len */
if (off > sizeof (struct tcphdr)) {
+
if (isipv6) {
+#ifdef INET6
IP6_EXTHDR_CHECK(m, off0, off, );
ip6 = mtod(m, struct ip6_hdr *);
th = (struct tcphdr *)((caddr_t)ip6 + off0);
+#endif
} else {
if (m->m_len < sizeof(struct ip) + off) {
if ((m = m_pullup(m, sizeof (struct ip) + off))
@@ -555,12 +565,14 @@
1, m->m_pkthdr.rcvif);
}
} else {
+#ifdef INET6
if (isipv6)
inp = in6_pcblookup_hash(&tcbinfo,
&ip6->ip6_src, th->th_sport,
&ip6->ip6_dst, th->th_dport,
1, m->m_pkthdr.rcvif);
else
+#endif
inp = in_pcblookup_hash(&tcbinfo,
ip->ip_src, th->th_sport,
ip->ip_dst, th->th_dport,
@@ -582,9 +594,11 @@
#endif
#ifdef FAST_IPSEC
if (isipv6) {
+#ifdef INET6
if (inp != NULL && ipsec6_in_reject(m, inp)) {
goto drop;
}
+#endif
} else
if (inp != NULL && ipsec4_in_reject(m, inp)) {
goto drop;
@@ -606,12 +620,14 @@
#endif
if (isipv6) {
+#ifdef INET6
strcpy(dbuf, "[");
strcpy(sbuf, "[");
strcat(dbuf, ip6_sprintf(&ip6->ip6_dst));
strcat(sbuf, ip6_sprintf(&ip6->ip6_src));
strcat(dbuf, "]");
strcat(sbuf, "]");
+#endif
} else {
strcpy(dbuf, inet_ntoa(ip->ip_dst));
strcpy(sbuf, inet_ntoa(ip->ip_src));
@@ -2611,17 +2627,23 @@
sizeof (struct ip6_hdr) + sizeof (struct tcphdr) :
sizeof (struct tcpiphdr);
#else
- const int isipv6 = 0;
+// const int isipv6 = 0;
const size_t min_protoh = sizeof (struct tcpiphdr);
#endif
+#ifdef INET6
if (isipv6)
rt = tcp_rtlookup6(&inp->inp_inc);
else
+#endif
rt = tcp_rtlookup(&inp->inp_inc);
if (rt == NULL) {
- tp->t_maxopd = tp->t_maxseg =
+ tp->t_maxopd = tp->t_maxseg =
+#ifdef INET6
isipv6 ? tcp_v6mssdflt : tcp_mssdflt;
+#else
+ tcp_mssdflt;
+#endif
return;
}
ifp = rt->rt_ifp;
@@ -2639,7 +2661,11 @@
* in this case we use tcp_mssdflt.
*/
if (offer == 0)
+#ifdef INET6
offer = isipv6 ? tcp_v6mssdflt : tcp_mssdflt;
+#else
+ offer = tcp_mssdflt;
+#endif
else
/*
* Sanity check: make sure that maxopd will be large
@@ -2685,16 +2711,20 @@
if (rt->rt_rmx.rmx_mtu)
mss = rt->rt_rmx.rmx_mtu - min_protoh;
else {
+#ifdef INET6
if (isipv6) {
mss = nd_ifinfo[rt->rt_ifp->if_index].linkmtu -
min_protoh;
if (!in6_localaddr(&inp->in6p_faddr))
mss = min(mss, tcp_v6mssdflt);
} else {
+#endif
mss = ifp->if_mtu - min_protoh;
if (!in_localaddr(inp->inp_faddr))
mss = min(mss, tcp_mssdflt);
+#ifdef INET6
}
+#endif
}
mss = min(mss, offer);
/*
@@ -2766,9 +2796,11 @@
*/
if (tcp_do_rfc3390)
tp->snd_cwnd = min(4 * mss, max(2 * mss, 4380));
+#ifdef INET6
else if ((isipv6 && in6_localaddr(&inp->in6p_faddr)) ||
(!isipv6 && in_localaddr(inp->inp_faddr)))
tp->snd_cwnd = mss * ss_fltsz_local;
+#endif
else
tp->snd_cwnd = mss * ss_fltsz;
@@ -2798,16 +2830,21 @@
sizeof (struct ip6_hdr) + sizeof (struct tcphdr) :
sizeof (struct tcpiphdr);
#else
- const int isipv6 = 0;
const size_t min_protoh = sizeof (struct tcpiphdr);
#endif
+#ifdef INET6
if (isipv6)
rt = tcp_rtlookup6(&tp->t_inpcb->inp_inc);
else
+#endif
rt = tcp_rtlookup(&tp->t_inpcb->inp_inc);
if (rt == NULL)
+#ifdef INET6
return (isipv6 ? tcp_v6mssdflt : tcp_mssdflt);
+#else
+ return tcp_mssdflt;
+#endif
return (rt->rt_ifp->if_mtu - min_protoh);
}
More information about the freebsd-bugs
mailing list