CVS commit: [netbsd-6] src/sys/netinet
Module Name:src Committed By: martin Date: Fri Feb 9 14:09:35 UTC 2018 Modified Files: src/sys/netinet [netbsd-6]: ip_input.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1526): sys/netinet/ip_input.c: revision 1.366 Disable ip_allowsrcrt and ip_forwsrcrt. Enabling them by default was a completely dumb idea, because they have security implications. By sending an IPv4 packet containing an LSRR option, an attacker will cause the system to forward the packet to another IPv4 address - and this way he white-washes the source of the packet. It is also possible for an attacker to reach hidden networks: if a server has a public address, and a private one on an internal network (network which has several internal machines connected), the attacker can send a packet with: source = 0.0.0.0 destination = public address of the server LSRR first address = address of a machine on the internal network And the packet will be forwarded, by the server, to the internal machine, in some cases even with the internal IP address of the server as a source. To generate a diff of this commit: cvs rdiff -u -r1.298 -r1.298.2.1 src/sys/netinet/ip_input.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/netinet/ip_input.c diff -u src/sys/netinet/ip_input.c:1.298 src/sys/netinet/ip_input.c:1.298.2.1 --- src/sys/netinet/ip_input.c:1.298 Mon Jan 9 14:31:22 2012 +++ src/sys/netinet/ip_input.c Fri Feb 9 14:09:35 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_input.c,v 1.298 2012/01/09 14:31:22 liamjfoy Exp $ */ +/* $NetBSD: ip_input.c,v 1.298.2.1 2018/02/09 14:09:35 martin Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.298 2012/01/09 14:31:22 liamjfoy Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.298.2.1 2018/02/09 14:09:35 martin Exp $"); #include "opt_inet.h" #include "opt_compat_netbsd.h" @@ -161,10 +161,10 @@ __KERNEL_RCSID(0, "$NetBSD: ip_input.c,v #define IPSENDREDIRECTS 1 #endif #ifndef IPFORWSRCRT -#define IPFORWSRCRT 1 /* forward source-routed packets */ +#define IPFORWSRCRT 0 /* forward source-routed packets */ #endif #ifndef IPALLOWSRCRT -#define IPALLOWSRCRT 1 /* allow source-routed packets */ +#define IPALLOWSRCRT 0 /* allow source-routed packets */ #endif #ifndef IPMTUDISC #define IPMTUDISC 1
CVS commit: [netbsd-6] src/sys/netinet
Module Name:src Committed By: snj Date: Sun Feb 5 06:07:36 UTC 2017 Modified Files: src/sys/netinet [netbsd-6]: if_arp.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1432): sys/netinet/if_arp.c: 1.238, 1.239 via patch Make sure the protocol address length equals that of IPv4. Also, make sure the hardware address length equals that of the interface we received the packet on. Otherwise a packet could easily set them both to zero and make the kernel read beyond the allocated mbuf, which is terrible. Note: for the latter we drop the packet instead of replying, since it is malformed. Note: I also added an ugly hack in CARP, since it apparently expects at least six bytes. -- Add some checks, mostly same as in_arpinput. To generate a diff of this commit: cvs rdiff -u -r1.154.2.2 -r1.154.2.3 src/sys/netinet/if_arp.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/netinet/if_arp.c diff -u src/sys/netinet/if_arp.c:1.154.2.2 src/sys/netinet/if_arp.c:1.154.2.3 --- src/sys/netinet/if_arp.c:1.154.2.2 Sun Nov 15 17:51:52 2015 +++ src/sys/netinet/if_arp.c Sun Feb 5 06:07:36 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_arp.c,v 1.154.2.2 2015/11/15 17:51:52 bouyer Exp $ */ +/* $NetBSD: if_arp.c,v 1.154.2.3 2017/02/05 06:07:36 snj Exp $ */ /*- * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.154.2.2 2015/11/15 17:51:52 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.154.2.3 2017/02/05 06:07:36 snj Exp $"); #include "opt_ddb.h" #include "opt_inet.h" @@ -975,6 +975,9 @@ in_arpinput(struct mbuf *m) break; } + if (ah->ar_pln != sizeof(struct in_addr)) + goto out; + memcpy(, ar_spa(ah), sizeof (isaddr)); memcpy(, ar_tpa(ah), sizeof (itaddr)); @@ -1005,7 +1008,10 @@ in_arpinput(struct mbuf *m) ((ia->ia_ifp->if_flags & (IFF_UP|IFF_RUNNING)) == (IFF_UP|IFF_RUNNING))) { index++; + + /* XXX: ar_hln? */ if (ia->ia_ifp == m->m_pkthdr.rcvif && + (ah->ar_hln >= 6) && carp_iamatch(ia, ar_sha(ah), , index)) { break; @@ -1037,6 +1043,14 @@ in_arpinput(struct mbuf *m) } #endif + if (ah->ar_hln != ifp->if_addrlen) { + ARP_STATINC(ARP_STAT_RCVBADLEN); + log(LOG_WARNING, + "arp from %s: addr len: new %d, i/f %d (ignored)\n", + in_fmtaddr(isaddr), ah->ar_hln, ifp->if_addrlen); + goto out; + } + if (ia == NULL) { INADDR_TO_IA(isaddr, ia); while ((ia != NULL) && ia->ia_ifp != m->m_pkthdr.rcvif) @@ -1131,14 +1145,7 @@ in_arpinput(struct mbuf *m) "arp from %s: new addr len %d, was %d\n", in_fmtaddr(isaddr), ah->ar_hln, sdl->sdl_alen); } - if (ifp->if_addrlen != ah->ar_hln) { - ARP_STATINC(ARP_STAT_RCVBADLEN); - log(LOG_WARNING, - "arp from %s: addr len: new %d, i/f %d (ignored)\n", - in_fmtaddr(isaddr), ah->ar_hln, - ifp->if_addrlen); - goto reply; - } + #if NTOKEN > 0 /* * XXX uses m_data and assumes the complete answer including @@ -1437,6 +1444,10 @@ in_revarpinput(struct mbuf *m) tha = ar_tha(ah); if (tha == NULL) goto out; + if (ah->ar_pln != sizeof(struct in_addr)) + goto out; + if (ah->ar_hln != ifp->if_sadl->sdl_alen) + goto out; if (memcmp(tha, CLLADDR(ifp->if_sadl), ifp->if_sadl->sdl_alen)) goto out; memcpy(_ip, ar_spa(ah), sizeof(srv_ip));
CVS commit: [netbsd-6] src/sys/netinet
Module Name:src Committed By: bouyer Date: Sun Aug 28 10:49:45 UTC 2016 Modified Files: src/sys/netinet [netbsd-6]: ip_carp.c Log Message: Pull up following revision(s) (requested by is in ticket #1393): sys/netinet/ip_carp.c: revision 1.75 Workaround for PR 47013 by bouyer@. Only works for mixed IPv4/IPv6 environemnts, not for pure-IPv6 yet. A real fix is still needed. To generate a diff of this commit: cvs rdiff -u -r1.47.4.4 -r1.47.4.5 src/sys/netinet/ip_carp.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/netinet/ip_carp.c diff -u src/sys/netinet/ip_carp.c:1.47.4.4 src/sys/netinet/ip_carp.c:1.47.4.5 --- src/sys/netinet/ip_carp.c:1.47.4.4 Sat Aug 27 14:39:10 2016 +++ src/sys/netinet/ip_carp.c Sun Aug 28 10:49:45 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_carp.c,v 1.47.4.4 2016/08/27 14:39:10 bouyer Exp $ */ +/* $NetBSD: ip_carp.c,v 1.47.4.5 2016/08/28 10:49:45 bouyer Exp $ */ /* $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $ */ /* @@ -31,7 +31,7 @@ #include "opt_mbuftrace.h" #include -__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.47.4.4 2016/08/27 14:39:10 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.47.4.5 2016/08/28 10:49:45 bouyer Exp $"); /* * TODO: @@ -1086,7 +1086,7 @@ carp_send_ad(void *v) } } #endif /* INET */ -#ifdef INET6 +#ifdef INET6_notyet if (sc->sc_naddrs6) { struct ip6_hdr *ip6; @@ -1494,7 +1494,7 @@ carp_setrun(struct carp_softc *sc, sa_fa callout_schedule(>sc_md_tmo, tvtohz()); break; #endif /* INET */ -#ifdef INET6 +#ifdef INET6_notyet case AF_INET6: callout_schedule(>sc_md6_tmo, tvtohz()); break; @@ -1502,8 +1502,10 @@ carp_setrun(struct carp_softc *sc, sa_fa default: if (sc->sc_naddrs) callout_schedule(>sc_md_tmo, tvtohz()); +#ifdef INET6_notyet if (sc->sc_naddrs6) callout_schedule(>sc_md6_tmo, tvtohz()); +#endif /* INET6 */ break; } break;
CVS commit: [netbsd-6] src/sys/netinet
Module Name:src Committed By: bouyer Date: Sat Aug 27 14:39:10 UTC 2016 Modified Files: src/sys/netinet [netbsd-6]: ip_carp.c Log Message: Pull up following revision(s) (requested by is in ticket #1394): sys/netinet/ip_carp.c: revision 1.76 Print the IPv6 or IPv4 source addresses of packets with wrong hash, to help debugging. To generate a diff of this commit: cvs rdiff -u -r1.47.4.3 -r1.47.4.4 src/sys/netinet/ip_carp.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/netinet/ip_carp.c diff -u src/sys/netinet/ip_carp.c:1.47.4.3 src/sys/netinet/ip_carp.c:1.47.4.4 --- src/sys/netinet/ip_carp.c:1.47.4.3 Tue Jun 3 15:34:00 2014 +++ src/sys/netinet/ip_carp.c Sat Aug 27 14:39:10 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_carp.c,v 1.47.4.3 2014/06/03 15:34:00 msaitoh Exp $ */ +/* $NetBSD: ip_carp.c,v 1.47.4.4 2016/08/27 14:39:10 bouyer Exp $ */ /* $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $ */ /* @@ -31,7 +31,7 @@ #include "opt_mbuftrace.h" #include -__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.47.4.3 2014/06/03 15:34:00 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.47.4.4 2016/08/27 14:39:10 bouyer Exp $"); /* * TODO: @@ -92,6 +92,7 @@ __KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v #include #include #include +#include #endif #include @@ -673,9 +674,29 @@ carp_proto_input_c(struct mbuf *m, struc /* verify the hash */ if (carp_hmac_verify(sc, ch->carp_counter, ch->carp_md)) { + struct ip *ip; + struct ip6_hdr *ip6; + CARP_STATINC(CARP_STAT_BADAUTH); sc->sc_if.if_ierrors++; - CARP_LOG(sc, ("incorrect hash")); + + switch(af) { + + case AF_INET: + ip = mtod(m, struct ip *); + CARP_LOG(sc, ("incorrect hash from %s", + in_fmtaddr(ip->ip_src))); + break; + + case AF_INET6: + ip6 = mtod(m, struct ip6_hdr *); + CARP_LOG(sc, ("incorrect hash from %s", +ip6_sprintf(>ip6_src))); + break; + + default: CARP_LOG(sc, ("incorrect hash")); + break; + } m_freem(m); return; }
CVS commit: [netbsd-6] src/sys/netinet
Module Name:src Committed By: bouyer Date: Sun Nov 15 17:51:52 UTC 2015 Modified Files: src/sys/netinet [netbsd-6]: if_arp.c Log Message: Pull up following revision(s) (requested by ozaki-r in ticket #1328): sys/netinet/if_arp.c: revision 1.160 Add sysctl to selectively log arp packets from unknown network. (Adrien URBAN). To generate a diff of this commit: cvs rdiff -u -r1.154.2.1 -r1.154.2.2 src/sys/netinet/if_arp.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/netinet/if_arp.c diff -u src/sys/netinet/if_arp.c:1.154.2.1 src/sys/netinet/if_arp.c:1.154.2.2 --- src/sys/netinet/if_arp.c:1.154.2.1 Tue Jun 3 15:34:00 2014 +++ src/sys/netinet/if_arp.c Sun Nov 15 17:51:52 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: if_arp.c,v 1.154.2.1 2014/06/03 15:34:00 msaitoh Exp $ */ +/* $NetBSD: if_arp.c,v 1.154.2.2 2015/11/15 17:51:52 bouyer Exp $ */ /*- * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.154.2.1 2014/06/03 15:34:00 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.154.2.2 2015/11/15 17:51:52 bouyer Exp $"); #include "opt_ddb.h" #include "opt_inet.h" @@ -194,6 +194,7 @@ static int arp_drainwanted; static int log_movements = 1; static int log_permanent_modify = 1; static int log_wrong_iface = 1; +static int log_unknown_network = 1; /* * this should be elsewhere. @@ -1306,17 +1307,20 @@ arplookup1(struct mbuf *m, const struct return (struct llinfo_arp *)rt->rt_llinfo; if (create) { - if (rt->rt_flags & RTF_GATEWAY) - why = "host is not on local network"; - else if ((rt->rt_flags & RTF_LLINFO) == 0) { + if (rt->rt_flags & RTF_GATEWAY) { + if (log_unknown_network) +why = "host is not on local network"; + } else if ((rt->rt_flags & RTF_LLINFO) == 0) { ARP_STATINC(ARP_STAT_ALLOCFAIL); why = "could not allocate llinfo"; } else why = "gateway route is not ours"; - log(LOG_DEBUG, "arplookup: unable to enter address" - " for %s@%s on %s (%s)\n", - in_fmtaddr(*addr), lla_snprintf(ar_sha(ah), ah->ar_hln), - (ifp) ? ifp->if_xname : "null", why); + if (why) { + log(LOG_DEBUG, "arplookup: unable to enter address" + " for %s@%s on %s (%s)\n", in_fmtaddr(*addr), + lla_snprintf(ar_sha(ah), ah->ar_hln), + (ifp) ? ifp->if_xname : "null", why); + } if (rt->rt_refcnt <= 0 && (rt->rt_flags & RTF_CLONED) != 0) { rtrequest(RTM_DELETE, rt_getkey(rt), rt->rt_gateway, rt_mask(rt), rt->rt_flags, NULL); @@ -1708,6 +1712,13 @@ sysctl_net_inet_arp_setup(struct sysctll " interface"), NULL, 0, _wrong_iface, 0, CTL_NET,PF_INET, node->sysctl_num, CTL_CREATE, CTL_EOL); + + sysctl_createv(clog, 0, NULL, NULL, + CTLFLAG_PERMANENT|CTLFLAG_READWRITE, + CTLTYPE_INT, "log_unknown_network", + SYSCTL_DESCR("log ARP packets from non-local network"), + NULL, 0, _unknown_network, 0, + CTL_NET,PF_INET, node->sysctl_num, CTL_CREATE, CTL_EOL); } #endif /* INET */
CVS commit: [netbsd-6] src/sys/netinet
Module Name:src Committed By: martin Date: Fri Jul 24 07:40:17 UTC 2015 Modified Files: src/sys/netinet [netbsd-6]: tcp_input.c tcp_output.c Log Message: Pull up following revision(s) (requested by matt in ticket #1315): sys/netinet/tcp_output.c: revision 1.184 sys/netinet/tcp_input.c: revision 1.343 If we are sending a window probe and there's unacked data in the socket, make sure at least the persist timer is running. Make sure that snd_win doesn't go negative. To generate a diff of this commit: cvs rdiff -u -r1.321 -r1.321.2.1 src/sys/netinet/tcp_input.c cvs rdiff -u -r1.173.2.1 -r1.173.2.2 src/sys/netinet/tcp_output.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/netinet/tcp_input.c diff -u src/sys/netinet/tcp_input.c:1.321 src/sys/netinet/tcp_input.c:1.321.2.1 --- src/sys/netinet/tcp_input.c:1.321 Wed Jan 11 14:39:08 2012 +++ src/sys/netinet/tcp_input.c Fri Jul 24 07:40:17 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_input.c,v 1.321 2012/01/11 14:39:08 drochner Exp $ */ +/* $NetBSD: tcp_input.c,v 1.321.2.1 2015/07/24 07:40:17 martin Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -148,7 +148,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: tcp_input.c,v 1.321 2012/01/11 14:39:08 drochner Exp $); +__KERNEL_RCSID(0, $NetBSD: tcp_input.c,v 1.321.2.1 2015/07/24 07:40:17 martin Exp $); #include opt_inet.h #include opt_ipsec.h @@ -2719,7 +2719,10 @@ after_listen: tp-t_lastm = NULL; sbdrop(so-so_snd, acked); tp-t_lastoff -= acked; - tp-snd_wnd -= acked; + if (tp-snd_wnd acked) +tp-snd_wnd -= acked; + else +tp-snd_wnd = 0; ourfinisacked = 0; } sowwakeup(so); Index: src/sys/netinet/tcp_output.c diff -u src/sys/netinet/tcp_output.c:1.173.2.1 src/sys/netinet/tcp_output.c:1.173.2.2 --- src/sys/netinet/tcp_output.c:1.173.2.1 Mon Nov 3 23:05:45 2014 +++ src/sys/netinet/tcp_output.c Fri Jul 24 07:40:17 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_output.c,v 1.173.2.1 2014/11/03 23:05:45 msaitoh Exp $ */ +/* $NetBSD: tcp_output.c,v 1.173.2.2 2015/07/24 07:40:17 martin Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -135,7 +135,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: tcp_output.c,v 1.173.2.1 2014/11/03 23:05:45 msaitoh Exp $); +__KERNEL_RCSID(0, $NetBSD: tcp_output.c,v 1.173.2.2 2015/07/24 07:40:17 martin Exp $); #include opt_inet.h #include opt_ipsec.h @@ -1527,14 +1527,24 @@ send: * of retransmit time. */ timer: - if (TCP_TIMER_ISARMED(tp, TCPT_REXMT) == 0 - ((sack_rxmit tp-snd_nxt != tp-snd_max) || - tp-snd_nxt != tp-snd_una)) { - if (TCP_TIMER_ISARMED(tp, TCPT_PERSIST)) { -TCP_TIMER_DISARM(tp, TCPT_PERSIST); + if (TCP_TIMER_ISARMED(tp, TCPT_REXMT) == 0) { + if ((sack_rxmit tp-snd_nxt != tp-snd_max) + || tp-snd_nxt != tp-snd_una) { +if (TCP_TIMER_ISARMED(tp, TCPT_PERSIST)) { + TCP_TIMER_DISARM(tp, TCPT_PERSIST); + tp-t_rxtshift = 0; +} +TCP_TIMER_ARM(tp, TCPT_REXMT, tp-t_rxtcur); + } else if (len == 0 so-so_snd.sb_cc 0 + TCP_TIMER_ISARMED(tp, TCPT_PERSIST) == 0) { +/* + * If we are sending a window probe and there's + * unacked data in the socket, make sure at + * least the persist timer is running. + */ tp-t_rxtshift = 0; +tcp_setpersist(tp); } - TCP_TIMER_ARM(tp, TCPT_REXMT, tp-t_rxtcur); } } else if (SEQ_GT(tp-snd_nxt + len, tp-snd_max))
CVS commit: [netbsd-6] src/sys/netinet
Module Name:src Committed By: msaitoh Date: Mon Nov 3 23:05:45 UTC 2014 Modified Files: src/sys/netinet [netbsd-6]: tcp_output.c Log Message: Pull up following revision(s) (requested by christos in ticket #1174): sys/netinet/tcp_output.c: revision 1.178 Avoid stack overflow when SACK and TCP_SIGNATURE are both present. Thanks to Jonathan Looney for pointing this out. To generate a diff of this commit: cvs rdiff -u -r1.173 -r1.173.2.1 src/sys/netinet/tcp_output.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/netinet/tcp_output.c diff -u src/sys/netinet/tcp_output.c:1.173 src/sys/netinet/tcp_output.c:1.173.2.1 --- src/sys/netinet/tcp_output.c:1.173 Sat Dec 31 20:41:59 2011 +++ src/sys/netinet/tcp_output.c Mon Nov 3 23:05:45 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_output.c,v 1.173 2011/12/31 20:41:59 christos Exp $ */ +/* $NetBSD: tcp_output.c,v 1.173.2.1 2014/11/03 23:05:45 msaitoh Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -135,7 +135,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: tcp_output.c,v 1.173 2011/12/31 20:41:59 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: tcp_output.c,v 1.173.2.1 2014/11/03 23:05:45 msaitoh Exp $); #include opt_inet.h #include opt_ipsec.h @@ -561,6 +561,7 @@ tcp_output(struct tcpcb *tp) #endif struct tcphdr *th; u_char opt[MAX_TCPOPTLEN]; +#define OPT_FITS(more) ((optlen + (more)) sizeof(opt)) unsigned optlen, hdrlen, packetlen; unsigned int sack_numblks; int idle, sendalot, txsegsize, rxsegsize; @@ -1127,7 +1128,7 @@ send: tp-snd_nxt = tp-iss; tp-t_ourmss = tcp_mss_to_advertise(synrt != NULL ? synrt-rt_ifp : NULL, af); - if ((tp-t_flags TF_NOOPT) == 0) { + if ((tp-t_flags TF_NOOPT) == 0 OPT_FITS(4)) { opt[0] = TCPOPT_MAXSEG; opt[1] = 4; opt[2] = (tp-t_ourmss 8) 0xff; @@ -1136,7 +1137,8 @@ send: if ((tp-t_flags TF_REQ_SCALE) ((flags TH_ACK) == 0 || - (tp-t_flags TF_RCVD_SCALE))) { + (tp-t_flags TF_RCVD_SCALE)) + OPT_FITS(4)) { *((u_int32_t *) (opt + optlen)) = htonl( TCPOPT_NOP 24 | TCPOPT_WINDOW 16 | @@ -1144,7 +1146,7 @@ send: tp-request_r_scale); optlen += 4; } - if (tcp_do_sack) { + if (tcp_do_sack OPT_FITS(4)) { u_int8_t *cp = (u_int8_t *)(opt + optlen); cp[0] = TCPOPT_SACK_PERMITTED; @@ -1164,7 +1166,7 @@ send: if ((tp-t_flags (TF_REQ_TSTMP|TF_NOOPT)) == TF_REQ_TSTMP (flags TH_RST) == 0 ((flags (TH_SYN|TH_ACK)) == TH_SYN || - (tp-t_flags TF_RCVD_TSTMP))) { + (tp-t_flags TF_RCVD_TSTMP)) OPT_FITS(TCPOLEN_TSTAMP_APPA)) { u_int32_t *lp = (u_int32_t *)(opt + optlen); /* Form timestamp option as shown in appendix A of RFC 1323. */ @@ -1188,30 +1190,33 @@ send: struct ipqent *tiqe; sack_len = sack_numblks * 8 + 2; - bp[0] = TCPOPT_NOP; - bp[1] = TCPOPT_NOP; - bp[2] = TCPOPT_SACK; - bp[3] = sack_len; - if ((tp-rcv_sack_flags TCPSACK_HAVED) != 0) { - sack_numblks--; - *lp++ = htonl(tp-rcv_dsack_block.left); - *lp++ = htonl(tp-rcv_dsack_block.right); - tp-rcv_sack_flags = ~TCPSACK_HAVED; - } - for (tiqe = TAILQ_FIRST(tp-timeq); - sack_numblks 0; tiqe = TAILQ_NEXT(tiqe, ipqe_timeq)) { - KASSERT(tiqe != NULL); - sack_numblks--; - *lp++ = htonl(tiqe-ipqe_seq); - *lp++ = htonl(tiqe-ipqe_seq + tiqe-ipqe_len + - ((tiqe-ipqe_flags TH_FIN) != 0 ? 1 : 0)); + if (OPT_FITS(sack_len + 2)) { + bp[0] = TCPOPT_NOP; + bp[1] = TCPOPT_NOP; + bp[2] = TCPOPT_SACK; + bp[3] = sack_len; + if ((tp-rcv_sack_flags TCPSACK_HAVED) != 0) { +sack_numblks--; +*lp++ = htonl(tp-rcv_dsack_block.left); +*lp++ = htonl(tp-rcv_dsack_block.right); +tp-rcv_sack_flags = ~TCPSACK_HAVED; + } + for (tiqe = TAILQ_FIRST(tp-timeq); + sack_numblks 0; + tiqe = TAILQ_NEXT(tiqe, ipqe_timeq)) { +KASSERT(tiqe != NULL); +sack_numblks--; +*lp++ = htonl(tiqe-ipqe_seq); +*lp++ = htonl(tiqe-ipqe_seq + tiqe-ipqe_len + +((tiqe-ipqe_flags TH_FIN) != 0 ? 1 : 0)); + } + optlen += sack_len + 2; } - optlen += sack_len + 2; } TCP_REASS_UNLOCK(tp); #ifdef TCP_SIGNATURE - if (tp-t_flags TF_SIGNATURE) { + if ((tp-t_flags TF_SIGNATURE) OPT_FITS(TCPOLEN_SIGNATURE + 2)) { u_char *bp; /* * Initialize TCP-MD5 option (RFC2385)
CVS commit: [netbsd-6] src/sys/netinet
Module Name:src Committed By: msaitoh Date: Fri Apr 11 08:52:14 UTC 2014 Modified Files: src/sys/netinet [netbsd-6]: ip_carp.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1043): sys/netinet/ip_carp.c: revision 1.53 Proper MBUFTRACE handling. Without it, ec_tx_mowner, ec_rx_mowner and ifp-if_mowner would be used uninitialised. To generate a diff of this commit: cvs rdiff -u -r1.47.4.1 -r1.47.4.2 src/sys/netinet/ip_carp.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/netinet/ip_carp.c diff -u src/sys/netinet/ip_carp.c:1.47.4.1 src/sys/netinet/ip_carp.c:1.47.4.2 --- src/sys/netinet/ip_carp.c:1.47.4.1 Mon Apr 2 18:25:35 2012 +++ src/sys/netinet/ip_carp.c Fri Apr 11 08:52:14 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_carp.c,v 1.47.4.1 2012/04/02 18:25:35 riz Exp $ */ +/* $NetBSD: ip_carp.c,v 1.47.4.2 2014/04/11 08:52:14 msaitoh Exp $ */ /* $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $ */ /* @@ -28,9 +28,10 @@ */ #include opt_inet.h +#include opt_mbuftrace.h #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ip_carp.c,v 1.47.4.1 2012/04/02 18:25:35 riz Exp $); +__KERNEL_RCSID(0, $NetBSD: ip_carp.c,v 1.47.4.2 2014/04/11 08:52:14 msaitoh Exp $); /* * TODO: @@ -159,6 +160,13 @@ static percpu_t *carpstat_percpu; #define CARP_STATINC(x) _NET_STATINC(carpstat_percpu, x) +#ifdef MBUFTRACE +static struct mowner carp_proto_mowner_rx = MOWNER_INIT(carp, rx); +static struct mowner carp_proto_mowner_tx = MOWNER_INIT(carp, tx); +static struct mowner carp_proto6_mowner_rx = MOWNER_INIT(carp6, rx); +static struct mowner carp_proto6_mowner_tx = MOWNER_INIT(carp6, tx); +#endif + struct carp_if { TAILQ_HEAD(, carp_softc) vhif_vrs; int vhif_nvrs; @@ -465,6 +473,7 @@ carp_proto_input(struct mbuf *m, ...) va_end(ap); CARP_STATINC(CARP_STAT_IPACKETS); + MCLAIM(m, carp_proto_mowner_rx); if (!carp_opts[CARPCTL_ALLOW]) { m_freem(m); @@ -534,6 +543,7 @@ carp6_proto_input(struct mbuf **mp, int u_int len; CARP_STATINC(CARP_STAT_IPACKETS6); + MCLAIM(m, carp_proto6_mowner_rx); if (!carp_opts[CARPCTL_ALLOW]) { m_freem(m); @@ -802,6 +812,19 @@ carp_clone_create(struct if_clone *ifc, carp_set_enaddr(sc); LIST_INIT(sc-sc_ac.ec_multiaddrs); bpf_attach(ifp, DLT_EN10MB, ETHER_HDR_LEN); +#ifdef MBUFTRACE + strlcpy(sc-sc_ac.ec_tx_mowner.mo_name, ifp-if_xname, + sizeof(sc-sc_ac.ec_tx_mowner.mo_name)); + strlcpy(sc-sc_ac.ec_tx_mowner.mo_descr, tx, + sizeof(sc-sc_ac.ec_tx_mowner.mo_descr)); + strlcpy(sc-sc_ac.ec_rx_mowner.mo_name, ifp-if_xname, + sizeof(sc-sc_ac.ec_rx_mowner.mo_name)); + strlcpy(sc-sc_ac.ec_rx_mowner.mo_descr, rx, + sizeof(sc-sc_ac.ec_rx_mowner.mo_descr)); + MOWNER_ATTACH(sc-sc_ac.ec_tx_mowner); + MOWNER_ATTACH(sc-sc_ac.ec_rx_mowner); + ifp-if_mowner = sc-sc_ac.ec_tx_mowner; +#endif return (0); } @@ -967,6 +990,7 @@ carp_send_ad(void *v) /* XXX maybe less ? */ goto retry_later; } + MCLAIM(m, carp_proto_mowner_tx); len = sizeof(*ip) + sizeof(ch); m-m_pkthdr.len = len; m-m_pkthdr.rcvif = NULL; @@ -1047,6 +1071,7 @@ carp_send_ad(void *v) /* XXX maybe less ? */ goto retry_later; } + MCLAIM(m, carp_proto6_mowner_tx); len = sizeof(*ip6) + sizeof(ch); m-m_pkthdr.len = len; m-m_pkthdr.rcvif = NULL; @@ -2238,6 +2263,12 @@ carp_init(void) { sysctl_net_inet_carp_setup(NULL); +#ifdef MBUFTRACE + MOWNER_ATTACH(carp_proto_mowner_rx); + MOWNER_ATTACH(carp_proto_mowner_tx); + MOWNER_ATTACH(carp_proto6_mowner_rx); + MOWNER_ATTACH(carp_proto6_mowner_tx); +#endif } static void
CVS commit: [netbsd-6] src/sys/netinet
Module Name:src Committed By: bouyer Date: Sat Dec 14 19:29:29 UTC 2013 Modified Files: src/sys/netinet [netbsd-6]: tcp_usrreq.c Log Message: Pull up following revision(s) (requested by kefren in ticket #992): sys/netinet/tcp_usrreq.c: revision 1.170 Update TCP CB with new values on rfc1323 and mssdflt sysctl updates =46rom yasuoka-cj7txg5mjn14eiagz67...@public.gmane.org in kern/44254 To generate a diff of this commit: cvs rdiff -u -r1.162.2.2 -r1.162.2.3 src/sys/netinet/tcp_usrreq.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/netinet/tcp_usrreq.c diff -u src/sys/netinet/tcp_usrreq.c:1.162.2.2 src/sys/netinet/tcp_usrreq.c:1.162.2.3 --- src/sys/netinet/tcp_usrreq.c:1.162.2.2 Sun Oct 20 13:29:37 2013 +++ src/sys/netinet/tcp_usrreq.c Sat Dec 14 19:29:29 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_usrreq.c,v 1.162.2.2 2013/10/20 13:29:37 bouyer Exp $ */ +/* $NetBSD: tcp_usrreq.c,v 1.162.2.3 2013/12/14 19:29:29 bouyer Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -95,7 +95,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: tcp_usrreq.c,v 1.162.2.2 2013/10/20 13:29:37 bouyer Exp $); +__KERNEL_RCSID(0, $NetBSD: tcp_usrreq.c,v 1.162.2.3 2013/12/14 19:29:29 bouyer Exp $); #include opt_inet.h #include opt_ipsec.h @@ -1048,10 +1048,43 @@ sysctl_net_inet_tcp_mssdflt(SYSCTLFN_ARG return (EINVAL); tcp_mssdflt = mssdflt; + mutex_enter(softnet_lock); + tcp_tcpcb_template(); + mutex_exit(softnet_lock); + return (0); } /* + * sysctl helper for TCP CB template update + */ +static int +sysctl_update_tcpcb_template(SYSCTLFN_ARGS) +{ + int t, error; + struct sysctlnode node; + + /* follow procedures in sysctl(9) manpage */ + t = *(int *)rnode-sysctl_data; + node = *rnode; + node.sysctl_data = t; + error = sysctl_lookup(SYSCTLFN_CALL(node)); + if (error || newp == NULL) + return error; + + if (t 0) + return EINVAL; + + *(int *)rnode-sysctl_data = t; + + mutex_enter(softnet_lock); + tcp_tcpcb_template(); + mutex_exit(softnet_lock); + + return 0; +} + +/* * sysctl helper routine for setting port related values under * net.inet.ip and net.inet6.ip6. does basic range checking and does * additional checks for each type. this code has placed in @@ -1676,7 +1709,7 @@ sysctl_net_inet_tcp_setup2(struct sysctl CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, rfc1323, SYSCTL_DESCR(Enable RFC1323 TCP extensions), - NULL, 0, tcp_do_rfc1323, 0, + sysctl_update_tcpcb_template, 0, tcp_do_rfc1323, 0, CTL_NET, pf, IPPROTO_TCP, TCPCTL_RFC1323, CTL_EOL); sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, @@ -1776,13 +1809,13 @@ sysctl_net_inet_tcp_setup2(struct sysctl CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, win_scale, SYSCTL_DESCR(Use RFC1323 window scale options), - NULL, 0, tcp_do_win_scale, 0, + sysctl_update_tcpcb_template, 0, tcp_do_win_scale, 0, CTL_NET, pf, IPPROTO_TCP, TCPCTL_WSCALE, CTL_EOL); sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, timestamps, SYSCTL_DESCR(Use RFC1323 time stamp options), - NULL, 0, tcp_do_timestamps, 0, + sysctl_update_tcpcb_template, 0, tcp_do_timestamps, 0, CTL_NET, pf, IPPROTO_TCP, TCPCTL_TSTAMP, CTL_EOL); sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
CVS commit: [netbsd-6] src/sys/netinet
Module Name:src Committed By: bouyer Date: Sun Oct 20 13:29:37 UTC 2013 Modified Files: src/sys/netinet [netbsd-6]: tcp_usrreq.c Log Message: Pull up following revision(s) (requested by spz in ticket #967): sys/netinet/tcp_usrreq.c: revision 1.168 PR/48098: Brian Marcotte: Avoid kernel assertion for embryonic sockets that don't have credentials yet. XXX: pullup-6 To generate a diff of this commit: cvs rdiff -u -r1.162.2.1 -r1.162.2.2 src/sys/netinet/tcp_usrreq.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/netinet/tcp_usrreq.c diff -u src/sys/netinet/tcp_usrreq.c:1.162.2.1 src/sys/netinet/tcp_usrreq.c:1.162.2.2 --- src/sys/netinet/tcp_usrreq.c:1.162.2.1 Sat Mar 17 19:51:45 2012 +++ src/sys/netinet/tcp_usrreq.c Sun Oct 20 13:29:37 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_usrreq.c,v 1.162.2.1 2012/03/17 19:51:45 bouyer Exp $ */ +/* $NetBSD: tcp_usrreq.c,v 1.162.2.2 2013/10/20 13:29:37 bouyer Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -95,7 +95,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: tcp_usrreq.c,v 1.162.2.1 2012/03/17 19:51:45 bouyer Exp $); +__KERNEL_RCSID(0, $NetBSD: tcp_usrreq.c,v 1.162.2.2 2013/10/20 13:29:37 bouyer Exp $); #include opt_inet.h #include opt_ipsec.h @@ -1168,18 +1168,20 @@ sysctl_net_inet_ip_ports(SYSCTLFN_ARGS) static inline int copyout_uid(struct socket *sockp, void *oldp, size_t *oldlenp) { - size_t sz; - int error; - uid_t uid; - - uid = kauth_cred_geteuid(sockp-so_cred); if (oldp) { + size_t sz; + uid_t uid; + int error; + + if (sockp-so_cred == NULL) + return EPERM; + + uid = kauth_cred_geteuid(sockp-so_cred); sz = MIN(sizeof(uid), *oldlenp); - error = copyout(uid, oldp, sz); - if (error) + if ((error = copyout(uid, oldp, sz)) != 0) return error; } - *oldlenp = sizeof(uid); + *oldlenp = sizeof(uid_t); return 0; }
CVS commit: [netbsd-6] src/sys/netinet
Module Name:src Committed By: riz Date: Sun Mar 31 20:52:29 UTC 2013 Modified Files: src/sys/netinet [netbsd-6]: ip_icmp.c Log Message: Pull up following revision(s) (requested by fair in ticket #860): sys/netinet/ip_icmp.c: revision 1.130 PR/47693: Erik E. Fair: Add missing code to icmp handling. - While there, add the rest of the missing codes - Merge groups - Fix indentation To generate a diff of this commit: cvs rdiff -u -r1.128 -r1.128.2.1 src/sys/netinet/ip_icmp.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/netinet/ip_icmp.c diff -u src/sys/netinet/ip_icmp.c:1.128 src/sys/netinet/ip_icmp.c:1.128.2.1 --- src/sys/netinet/ip_icmp.c:1.128 Mon Jan 9 14:31:22 2012 +++ src/sys/netinet/ip_icmp.c Sun Mar 31 20:52:29 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_icmp.c,v 1.128 2012/01/09 14:31:22 liamjfoy Exp $ */ +/* $NetBSD: ip_icmp.c,v 1.128.2.1 2013/03/31 20:52:29 riz Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -94,7 +94,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ip_icmp.c,v 1.128 2012/01/09 14:31:22 liamjfoy Exp $); +__KERNEL_RCSID(0, $NetBSD: ip_icmp.c,v 1.128.2.1 2013/03/31 20:52:29 riz Exp $); #include opt_ipsec.h @@ -457,45 +457,42 @@ icmp_input(struct mbuf *m, ...) case ICMP_UNREACH: switch (code) { - case ICMP_UNREACH_NET: -code = PRC_UNREACH_NET; -break; - - case ICMP_UNREACH_HOST: -code = PRC_UNREACH_HOST; -break; - - case ICMP_UNREACH_PROTOCOL: -code = PRC_UNREACH_PROTOCOL; -break; + case ICMP_UNREACH_PROTOCOL: + code = PRC_UNREACH_PROTOCOL; + break; - case ICMP_UNREACH_PORT: -code = PRC_UNREACH_PORT; -break; + case ICMP_UNREACH_PORT: + code = PRC_UNREACH_PORT; + break; - case ICMP_UNREACH_SRCFAIL: -code = PRC_UNREACH_SRCFAIL; -break; + case ICMP_UNREACH_SRCFAIL: + code = PRC_UNREACH_SRCFAIL; + break; - case ICMP_UNREACH_NEEDFRAG: -code = PRC_MSGSIZE; -break; + case ICMP_UNREACH_NEEDFRAG: + code = PRC_MSGSIZE; + break; - case ICMP_UNREACH_NET_UNKNOWN: - case ICMP_UNREACH_NET_PROHIB: - case ICMP_UNREACH_TOSNET: -code = PRC_UNREACH_NET; -break; + case ICMP_UNREACH_NET: + case ICMP_UNREACH_NET_UNKNOWN: + case ICMP_UNREACH_NET_PROHIB: + case ICMP_UNREACH_TOSNET: + code = PRC_UNREACH_NET; + break; - case ICMP_UNREACH_HOST_UNKNOWN: - case ICMP_UNREACH_ISOLATED: - case ICMP_UNREACH_HOST_PROHIB: - case ICMP_UNREACH_TOSHOST: -code = PRC_UNREACH_HOST; -break; + case ICMP_UNREACH_HOST: + case ICMP_UNREACH_HOST_UNKNOWN: + case ICMP_UNREACH_ISOLATED: + case ICMP_UNREACH_HOST_PROHIB: + case ICMP_UNREACH_TOSHOST: + case ICMP_UNREACH_ADMIN_PROHIBIT: + case ICMP_UNREACH_HOST_PREC: + case ICMP_UNREACH_PREC_CUTOFF: + code = PRC_UNREACH_HOST; + break; - default: -goto badcode; + default: + goto badcode; } goto deliver;
CVS commit: [netbsd-6] src/sys/netinet
Module Name:src Committed By: jdc Date: Wed Jul 25 20:33:28 UTC 2012 Modified Files: src/sys/netinet [netbsd-6]: icmp6.h Log Message: Pull up revisions: src/sys/netinet/icmp6.h revisions 1.45,1.46 (requested by rmind in ticket #434). this commit contains two sets of unrelated changes: while I was here I checked other KAME implementations for their icmp6.h version, and thus: - added a define for MLDV2_LISTENER_REPORT from FreeBSD - added defines for the missing ICMP6_DST_UNREACH codes then on to what I actually wanted to do: - adds strings for the types and codes (encapsulated by ICMP6_STRINGS) for the use of npfctl and other tools that might want to parse human-friendly names instead of the corresponding number for ipv6-icmp types and codes. The strings are ordered such that their index is (as far as is practical) the number belonging to the name, which is why there are icmp6_type_err (use directly) and icmp6_type_info (add 128) grmblwhitespace/grmbl To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.44.2.1 src/sys/netinet/icmp6.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/netinet/icmp6.h diff -u src/sys/netinet/icmp6.h:1.44 src/sys/netinet/icmp6.h:1.44.2.1 --- src/sys/netinet/icmp6.h:1.44 Sat Dec 10 19:14:29 2011 +++ src/sys/netinet/icmp6.h Wed Jul 25 20:33:28 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: icmp6.h,v 1.44 2011/12/10 19:14:29 roy Exp $ */ +/* $NetBSD: icmp6.h,v 1.44.2.1 2012/07/25 20:33:28 jdc Exp $ */ /* $KAME: icmp6.h,v 1.84 2003/04/23 10:26:51 itojun Exp $ */ @@ -125,6 +125,7 @@ struct icmp6_hdr { #define ICMP6_FQDN_REPLY 140 /* FQDN reply */ #define ICMP6_NI_QUERY 139 /* node information request */ #define ICMP6_NI_REPLY 140 /* node information reply */ +#define MLDV2_LISTENER_REPORT 143 /* RFC3810 listener report */ /* The definitions below are experimental. TBA */ #define MLD_MTRACE_RESP 200 /* mtrace response(to sender) */ @@ -144,6 +145,9 @@ struct icmp6_hdr { #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */ #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */ #define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */ +#define ICMP6_DST_UNREACH_POLICY 5 /* source address failed ingress/egress policy */ +#define ICMP6_DST_UNREACH_REJROUTE 6 /* reject route to destination */ +#define ICMP6_DST_UNREACH_SOURCERT 7 /* error in source routing header */ #define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */ #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */ @@ -733,4 +737,41 @@ extern int icmp6_rediraccept; /* accept/ extern int icmp6_redirtimeout; /* cache time for redirect routes */ #endif /* _KERNEL */ +#ifdef ICMP6_STRINGS +/* Info: http://www.iana.org/assignments/icmpv6-parameters */ + +static const char * const icmp6_type_err[] = { + reserved0, unreach, packet_too_big, timxceed, paramprob, + NULL +}; + +static const char * const icmp6_type_info[] = { + echo, echoreply, + mcastlistenq, mcastlistenrep, mcastlistendone, + rtsol, rtadv, neighsol, neighadv, redirect, + routerrenum, nodeinfoq, nodeinfor, invneighsol, invneighrep, + mcastlistenrep2, haad_req, haad_rep, + mobile_psol, mobile_padv, cga_sol, cga_adv, + experimental150, mcast_rtadv, mcast_rtsol, mcast_rtterm, + fmipv6_msg, rpl_control, NULL +}; + +static const char * const icmp6_code_none[] = { none, NULL }; + +static const char * const icmp6_code_unreach[] = { + noroute, admin, beyondscope, addr, port, + srcaddr_policy, reject_route, source_route_err, NULL +}; + +static const char * const icmp6_code_timxceed[] = { + intrans, reass, NULL +}; + +static const char * const icmp6_code_paramprob[] = { + hdr_field, nxthdr_type, option, NULL +}; + +/* not all informational icmps that have codes have a names array */ +#endif + #endif /* !_NETINET_ICMP6_H_ */
CVS commit: [netbsd-6] src/sys/netinet
Module Name:src Committed By: riz Date: Wed Jun 13 19:12:24 UTC 2012 Modified Files: src/sys/netinet [netbsd-6]: in.c Log Message: Pull up following revision(s) (requested by gdt in ticket #330): sys/netinet/in.c: revision 1.143 Simply use the ifa_addr pointer, rather than taking its address. Resolves failure to match addresses in SIOC[GD]LIFADDR calls. Diagnosis and fix is due to Mark Keaton of BBN. To generate a diff of this commit: cvs rdiff -u -r1.142 -r1.142.2.1 src/sys/netinet/in.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/netinet/in.c diff -u src/sys/netinet/in.c:1.142 src/sys/netinet/in.c:1.142.2.1 --- src/sys/netinet/in.c:1.142 Mon Dec 12 00:06:39 2011 +++ src/sys/netinet/in.c Wed Jun 13 19:12:23 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: in.c,v 1.142 2011/12/12 00:06:39 roy Exp $ */ +/* $NetBSD: in.c,v 1.142.2.1 2012/06/13 19:12:23 riz Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -91,7 +91,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: in.c,v 1.142 2011/12/12 00:06:39 roy Exp $); +__KERNEL_RCSID(0, $NetBSD: in.c,v 1.142.2.1 2012/06/13 19:12:23 riz Exp $); #include opt_inet.h #include opt_inet_conf.h @@ -729,7 +729,7 @@ in_lifaddr_ioctl(struct socket *so, u_lo continue; if (cmp == 0) break; - candidate.s_addr = ((struct sockaddr_in *)ifa-ifa_addr)-sin_addr.s_addr; + candidate.s_addr = ((struct sockaddr_in *)ifa-ifa_addr)-sin_addr.s_addr; candidate.s_addr = mask.s_addr; if (candidate.s_addr == match.s_addr) break;
CVS commit: [netbsd-6] src/sys/netinet
Module Name:src Committed By: riz Date: Mon Apr 2 18:25:35 UTC 2012 Modified Files: src/sys/netinet [netbsd-6]: ip_carp.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #145): sys/netinet/ip_carp.c: revision 1.48 Do not sleep in callout context, this will hang the clock soft interrupt. Should fix PR kern/46217. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.47.4.1 src/sys/netinet/ip_carp.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/netinet/ip_carp.c diff -u src/sys/netinet/ip_carp.c:1.47 src/sys/netinet/ip_carp.c:1.47.4.1 --- src/sys/netinet/ip_carp.c:1.47 Sat Nov 19 22:51:25 2011 +++ src/sys/netinet/ip_carp.c Mon Apr 2 18:25:35 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_carp.c,v 1.47 2011/11/19 22:51:25 tls Exp $ */ +/* $NetBSD: ip_carp.c,v 1.47.4.1 2012/04/02 18:25:35 riz Exp $ */ /* $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $ */ /* @@ -30,7 +30,7 @@ #include opt_inet.h #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ip_carp.c,v 1.47 2011/11/19 22:51:25 tls Exp $); +__KERNEL_RCSID(0, $NetBSD: ip_carp.c,v 1.47.4.1 2012/04/02 18:25:35 riz Exp $); /* * TODO: @@ -1146,9 +1146,6 @@ carp_send_arp(struct carp_softc *sc) in = ifatoia(ifa)-ia_addr.sin_addr; arprequest(sc-sc_carpdev, in, in, CLLADDR(sc-sc_if.if_sadl)); - - /* XXX: why does this need to delay? */ - kpause(carpdel, false, MAX(1, mstohz(1)), NULL); } splx(s); } @@ -1170,9 +1167,6 @@ carp_send_na(struct carp_softc *sc) in6 = ifatoia6(ifa)-ia_addr.sin6_addr; nd6_na_output(sc-sc_carpdev, mcast, in6, ND_NA_FLAG_OVERRIDE, 1, NULL); - - /* XXX: why does this need to delay? */ - kpause(carpdel6, false, MAX(1, mstohz(1)), NULL); } splx(s); }
CVS commit: [netbsd-6] src/sys/netinet
Module Name:src Committed By: bouyer Date: Sat Mar 17 17:53:01 UTC 2012 Modified Files: src/sys/netinet [netbsd-6]: rfc6056.c Log Message: Pull up following revision(s) (requested by gson in ticket #122): sys/netinet/rfc6056.c: revision 1.5 Fix random kernel memory corruption by algo_doublehash(). And by random I don't mean just arbitary as in using an uninitialized pointer, but random as in corrupting the contents of memory addresses chosen using a crypto-strength random number generator. I believe this is the likely cause of multiple reports of random crashes over the last six months, including kern/45677 and kern/46096. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.4.4.1 src/sys/netinet/rfc6056.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/netinet/rfc6056.c diff -u src/sys/netinet/rfc6056.c:1.4 src/sys/netinet/rfc6056.c:1.4.4.1 --- src/sys/netinet/rfc6056.c:1.4 Sat Nov 19 22:51:25 2011 +++ src/sys/netinet/rfc6056.c Sat Mar 17 17:53:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: rfc6056.c,v 1.4 2011/11/19 22:51:25 tls Exp $ */ +/* $NetBSD: rfc6056.c,v 1.4.4.1 2012/03/17 17:53:01 bouyer Exp $ */ /* * Copyright 2011 Vlad Balan @@ -29,7 +29,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: rfc6056.c,v 1.4 2011/11/19 22:51:25 tls Exp $); +__KERNEL_RCSID(0, $NetBSD: rfc6056.c,v 1.4.4.1 2012/03/17 17:53:01 bouyer Exp $); #include opt_inet.h @@ -665,8 +665,9 @@ algo_doublehash(int algo, uint16_t *port uint16_t count, num_ephemeral; uint16_t mymin, mymax, lastport; uint16_t *next_ephemeral; - uint16_t offset, idx, myport; + uint16_t offset, myport; static uint16_t dhtable[8]; + size_t idx; int error; DPRINTF(%s called\n, __func__); @@ -688,7 +689,7 @@ algo_doublehash(int algo, uint16_t *port /* Ephemeral port selection function */ num_ephemeral = mymax - mymin + 1; offset = Fhash(inp_hdr); - idx = Fhash(inp_hdr); /* G */ + idx = Fhash(inp_hdr) % __arraycount(dhtable); /* G */ count = num_ephemeral; do {
CVS commit: [netbsd-6] src/sys/netinet
Module Name:src Committed By: bouyer Date: Sat Mar 17 19:51:46 UTC 2012 Modified Files: src/sys/netinet [netbsd-6]: tcp_usrreq.c Log Message: Pull up following revision(s) (requested by jruoho in ticket #124): sys/netinet/tcp_usrreq.c: revision 1.163 PR/46077: M. Nunberg: Stat should not fial on connecting socket. To generate a diff of this commit: cvs rdiff -u -r1.162 -r1.162.2.1 src/sys/netinet/tcp_usrreq.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/netinet/tcp_usrreq.c diff -u src/sys/netinet/tcp_usrreq.c:1.162 src/sys/netinet/tcp_usrreq.c:1.162.2.1 --- src/sys/netinet/tcp_usrreq.c:1.162 Thu Feb 2 19:43:07 2012 +++ src/sys/netinet/tcp_usrreq.c Sat Mar 17 19:51:45 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_usrreq.c,v 1.162 2012/02/02 19:43:07 tls Exp $ */ +/* $NetBSD: tcp_usrreq.c,v 1.162.2.1 2012/03/17 19:51:45 bouyer Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -95,7 +95,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: tcp_usrreq.c,v 1.162 2012/02/02 19:43:07 tls Exp $); +__KERNEL_RCSID(0, $NetBSD: tcp_usrreq.c,v 1.162.2.1 2012/03/17 19:51:45 bouyer Exp $); #include opt_inet.h #include opt_ipsec.h @@ -267,11 +267,11 @@ tcp_usrreq(struct socket *so, int req, * a (struct inpcb) pointed at by the socket, and this * structure will point at a subsidary (struct tcpcb). */ -#ifndef INET6 - if (inp == 0 req != PRU_ATTACH) -#else - if ((inp == 0 in6p == 0) req != PRU_ATTACH) + if ((inp == 0 +#ifdef INET6 + in6p == 0 #endif + ) (req != PRU_ATTACH req != PRU_SENSE)) { error = EINVAL; goto release;