CVS commit: [netbsd-5] src/sys/net
Module Name:src Committed By: msaitoh Date: Wed Sep 11 07:02:46 UTC 2013 Modified Files: src/sys/net [netbsd-5]: bpf.c Log Message: Pull up following revision(s) (requested by spz in ticket #1874): sys/net/bpf.c: revision 1.176 via patch PR/48198: Peter Bex: Avoid kernel panic caused by setting a very small bpf buffer size. To generate a diff of this commit: cvs rdiff -u -r1.141.6.2 -r1.141.6.3 src/sys/net/bpf.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/bpf.c diff -u src/sys/net/bpf.c:1.141.6.2 src/sys/net/bpf.c:1.141.6.3 --- src/sys/net/bpf.c:1.141.6.2 Tue Apr 5 06:10:50 2011 +++ src/sys/net/bpf.c Wed Sep 11 07:02:46 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: bpf.c,v 1.141.6.2 2011/04/05 06:10:50 riz Exp $ */ +/* $NetBSD: bpf.c,v 1.141.6.3 2013/09/11 07:02:46 msaitoh Exp $ */ /* * Copyright (c) 1990, 1991, 1993 @@ -39,7 +39,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: bpf.c,v 1.141.6.2 2011/04/05 06:10:50 riz Exp $); +__KERNEL_RCSID(0, $NetBSD: bpf.c,v 1.141.6.3 2013/09/11 07:02:46 msaitoh Exp $); #if defined(_KERNEL_OPT) #include opt_bpf.h @@ -1453,7 +1453,7 @@ catchpacket(struct bpf_d *d, u_char *pkt void *(*cpfn)(void *, const void *, size_t), struct timeval *tv) { struct bpf_hdr *hp; - int totlen, curlen; + int totlen, curlen, caplen; int hdrlen = d-bd_bif-bif_hdrlen; int do_wakeup = 0; @@ -1468,6 +1468,13 @@ catchpacket(struct bpf_d *d, u_char *pkt totlen = hdrlen + min(snaplen, pktlen); if (totlen d-bd_bufsize) totlen = d-bd_bufsize; + /* + * If we adjusted totlen to fit the bufsize, it could be that + * totlen is smaller than hdrlen because of the link layer header. + */ + caplen = totlen - hdrlen; + if (caplen 0) + caplen = 0; /* * Round up the end of the previous packet to the next longword. @@ -1507,10 +1514,11 @@ catchpacket(struct bpf_d *d, u_char *pkt hp-bh_tstamp = *tv; hp-bh_datalen = pktlen; hp-bh_hdrlen = hdrlen; + hp-bh_caplen = caplen; /* * Copy the packet data into the store buffer and update its length. */ - (*cpfn)((u_char *)hp + hdrlen, pkt, (hp-bh_caplen = totlen - hdrlen)); + (*cpfn)((u_char *)hp + hdrlen, pkt, caplen); d-bd_slen = curlen + totlen; /*
CVS commit: [netbsd-5] src/sys/net
Module Name:src Committed By: bouyer Date: Sun Feb 5 12:34:56 UTC 2012 Modified Files: src/sys/net [netbsd-5]: route.c Log Message: Pull up following revision(s) (requested by christos in ticket #1721): sys/net/route.c: revision 1.126 Count length from the beginning of the structure not the sa_data portion. =46rom skrll@ To generate a diff of this commit: cvs rdiff -u -r1.113.4.1 -r1.113.4.2 src/sys/net/route.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/route.c diff -u src/sys/net/route.c:1.113.4.1 src/sys/net/route.c:1.113.4.2 --- src/sys/net/route.c:1.113.4.1 Fri Apr 3 17:59:03 2009 +++ src/sys/net/route.c Sun Feb 5 12:34:55 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: route.c,v 1.113.4.1 2009/04/03 17:59:03 snj Exp $ */ +/* $NetBSD: route.c,v 1.113.4.2 2012/02/05 12:34:55 bouyer Exp $ */ /*- * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. @@ -93,7 +93,7 @@ #include opt_route.h #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: route.c,v 1.113.4.1 2009/04/03 17:59:03 snj Exp $); +__KERNEL_RCSID(0, $NetBSD: route.c,v 1.113.4.2 2012/02/05 12:34:55 bouyer Exp $); #include sys/param.h #include sys/sysctl.h @@ -847,8 +847,8 @@ rt_maskedcopy(const struct sockaddr *src const char *netmaskp = netmask-sa_data[0], *srcp = src-sa_data[0]; char *dstp = dst-sa_data[0]; - const char *maskend = dstp + MIN(netmask-sa_len, src-sa_len); - const char *srcend = dstp + src-sa_len; + const char *maskend = (char *)dst + MIN(netmask-sa_len, src-sa_len); + const char *srcend = (char *)dst + src-sa_len; dst-sa_len = src-sa_len; dst-sa_family = src-sa_family;
CVS commit: [netbsd-5] src/sys/net
Module Name:src Committed By: riz Date: Mon Aug 8 19:33:34 UTC 2011 Modified Files: src/sys/net [netbsd-5]: if.c Log Message: Pull up following revision(s) (requested by sborrill in ticket #1643): sys/net/if.c: revision 1.243 Prevent if_detach() from crashing while it walks the routing table to find and unlink routes that reference the detached ifnet: make if_rt_walktree() return ERESTART whenever it has deleted a route. Whenever rt_walktree() returns ERESTART, if_detach() restarts it. I believe that this fix resembles one by Jonathan Kollasch or by someone else, which has languished in a PR for too long. Sorry! Tested by me and by Jeff Rizzo. XXX It's supposed to be safe for rn_walktree() to apply to the routing XXX table a routine that may delete routes. Why isn't it safe in XXX practice? To generate a diff of this commit: cvs rdiff -u -r1.230.4.4 -r1.230.4.5 src/sys/net/if.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/if.c diff -u src/sys/net/if.c:1.230.4.4 src/sys/net/if.c:1.230.4.5 --- src/sys/net/if.c:1.230.4.4 Wed Feb 16 20:37:47 2011 +++ src/sys/net/if.c Mon Aug 8 19:33:34 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: if.c,v 1.230.4.4 2011/02/16 20:37:47 bouyer Exp $ */ +/* $NetBSD: if.c,v 1.230.4.5 2011/08/08 19:33:34 riz Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc. @@ -90,7 +90,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: if.c,v 1.230.4.4 2011/02/16 20:37:47 bouyer Exp $); +__KERNEL_RCSID(0, $NetBSD: if.c,v 1.230.4.5 2011/08/08 19:33:34 riz Exp $); #include opt_inet.h @@ -726,8 +726,10 @@ if_free_sadl(ifp); /* Walk the routing table looking for stragglers. */ - for (i = 0; i = AF_MAX; i++) - (void)rt_walktree(i, if_rt_walktree, ifp); + for (i = 0; i = AF_MAX; i++) { + while (rt_walktree(i, if_rt_walktree, ifp) == ERESTART) + ; + } DOMAIN_FOREACH(dp) { if (dp-dom_ifdetach != NULL ifp-if_afdata[dp-dom_family]) @@ -838,7 +840,7 @@ if (error != 0) printf(%s: warning: unable to delete rtentry @ %p, error = %d\n, ifp-if_xname, rt, error); - return 0; + return ERESTART; } /*
CVS commit: [netbsd-5] src/sys/net
Module Name:src Committed By: riz Date: Tue Apr 5 06:10:50 UTC 2011 Modified Files: src/sys/net [netbsd-5]: bpf.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1587): sys/net/bpf.c: revision 1.163 Allocate buffers with (M_WAITOK | M_CANFAIL) instead of M_NOWAIT. M_NOWAIT cause dhcpd on a low-memory server with lots of interfaces to occasionally fail to start with ENOBUFS; (M_WAITOK | M_CANFAIL) seems to fix this. Tested on 3 different dhcp servers. To generate a diff of this commit: cvs rdiff -u -r1.141.6.1 -r1.141.6.2 src/sys/net/bpf.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/bpf.c diff -u src/sys/net/bpf.c:1.141.6.1 src/sys/net/bpf.c:1.141.6.2 --- src/sys/net/bpf.c:1.141.6.1 Sat Apr 4 23:36:28 2009 +++ src/sys/net/bpf.c Tue Apr 5 06:10:50 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: bpf.c,v 1.141.6.1 2009/04/04 23:36:28 snj Exp $ */ +/* $NetBSD: bpf.c,v 1.141.6.2 2011/04/05 06:10:50 riz Exp $ */ /* * Copyright (c) 1990, 1991, 1993 @@ -39,7 +39,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: bpf.c,v 1.141.6.1 2009/04/04 23:36:28 snj Exp $); +__KERNEL_RCSID(0, $NetBSD: bpf.c,v 1.141.6.2 2011/04/05 06:10:50 riz Exp $); #if defined(_KERNEL_OPT) #include opt_bpf.h @@ -1528,10 +1528,10 @@ bpf_allocbufs(struct bpf_d *d) { - d-bd_fbuf = malloc(d-bd_bufsize, M_DEVBUF, M_NOWAIT); + d-bd_fbuf = malloc(d-bd_bufsize, M_DEVBUF, M_WAITOK | M_CANFAIL); if (!d-bd_fbuf) return (ENOBUFS); - d-bd_sbuf = malloc(d-bd_bufsize, M_DEVBUF, M_NOWAIT); + d-bd_sbuf = malloc(d-bd_bufsize, M_DEVBUF, M_WAITOK | M_CANFAIL); if (!d-bd_sbuf) { free(d-bd_fbuf, M_DEVBUF); return (ENOBUFS);
CVS commit: [netbsd-5] src/sys/net
Module Name:src Committed By: bouyer Date: Sun Mar 20 21:28:08 UTC 2011 Modified Files: src/sys/net [netbsd-5]: bpf_filter.c Log Message: Pull up following revision(s) (requested by spz in ticket #1571): sys/net/bpf_filter.c: revision 1.42 - 1.46 via patch Avoid stack memory disclosure by keeping track during filter validation time of initialized memory. Idea taken from linux. Use __CTASSERT Use kmem instead of malloc. Requested by rmind. Fix userland build. delint. To generate a diff of this commit: cvs rdiff -u -r1.35.4.1 -r1.35.4.2 src/sys/net/bpf_filter.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/bpf_filter.c diff -u src/sys/net/bpf_filter.c:1.35.4.1 src/sys/net/bpf_filter.c:1.35.4.2 --- src/sys/net/bpf_filter.c:1.35.4.1 Thu May 20 05:13:13 2010 +++ src/sys/net/bpf_filter.c Sun Mar 20 21:28:08 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: bpf_filter.c,v 1.35.4.1 2010/05/20 05:13:13 snj Exp $ */ +/* $NetBSD: bpf_filter.c,v 1.35.4.2 2011/03/20 21:28:08 bouyer Exp $ */ /*- * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -37,7 +37,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: bpf_filter.c,v 1.35.4.1 2010/05/20 05:13:13 snj Exp $); +__KERNEL_RCSID(0, $NetBSD: bpf_filter.c,v 1.35.4.2 2011/03/20 21:28:08 bouyer Exp $); #if 0 #if !(defined(lint) || defined(KERNEL)) @@ -48,6 +48,7 @@ #include sys/param.h #include sys/time.h +#include sys/kmem.h #include sys/endian.h #define EXTRACT_SHORT(p) be16dec(p) @@ -147,8 +148,7 @@ A = 0; X = 0; --pc; - /* CONSTCOND */ - while (1) { + for (;;) { ++pc; switch (pc-code) { @@ -157,6 +157,7 @@ return 0; #else abort(); + /*NOTREACHED*/ #endif case BPF_RET|BPF_K: return (u_int)pc-k; @@ -461,16 +462,38 @@ * The kernel needs to be able to verify an application's filter code. * Otherwise, a bogus program could easily crash the system. */ +CTASSERT(BPF_MEMWORDS == sizeof(uint16_t) * NBBY); + int -bpf_validate(struct bpf_insn *f, int len) +bpf_validate(struct bpf_insn *f, int signed_len) { - u_int i, from; - struct bpf_insn *p; + u_int i, from, len, ok = 0; + const struct bpf_insn *p; +#if defined(KERNEL) || defined(_KERNEL) + uint16_t *mem, invalid; + size_t size; +#endif - if (len 1 || len BPF_MAXINSNS) + len = (u_int)signed_len; + if (len 1) + return 0; +#if defined(KERNEL) || defined(_KERNEL) + if (len BPF_MAXINSNS) + return 0; +#endif + if (BPF_CLASS(f[len - 1].code) != BPF_RET) return 0; +#if defined(KERNEL) || defined(_KERNEL) + mem = kmem_zalloc(size = sizeof(*mem) * len, KM_SLEEP); + invalid = ~0; /* All is invalid on startup */ +#endif + for (i = 0; i len; ++i) { +#if defined(KERNEL) || defined(_KERNEL) + /* blend in any invalid bits for current pc */ + invalid |= mem[i]; +#endif p = f[i]; switch (BPF_CLASS(p-code)) { /* @@ -480,8 +503,22 @@ case BPF_LDX: switch (BPF_MODE(p-code)) { case BPF_MEM: +/* + * There's no maximum packet data size + * in userland. The runtime packet length + * check suffices. + */ +#if defined(KERNEL) || defined(_KERNEL) +/* + * More strict check with actual packet length + * is done runtime. + */ if (p-k = BPF_MEMWORDS) - return 0; + goto out; +/* check for current memory invalid */ +if (invalid (1 p-k)) + goto out; +#endif break; case BPF_ABS: case BPF_IND: @@ -490,13 +527,17 @@ case BPF_LEN: break; default: -return 0; +goto out; } break; case BPF_ST: case BPF_STX: if (p-k = BPF_MEMWORDS) -return 0; +goto out; +#if defined(KERNEL) || defined(_KERNEL) + /* validate the memory word */ + invalid = ~(1 p-k); +#endif break; case BPF_ALU: switch (BPF_OP(p-code)) { @@ -514,10 +555,10 @@ * Check for constant division by 0. */ if (BPF_SRC(p-code) == BPF_K p-k == 0) - return 0; + goto out; break; default: -return 0; +goto out; } break; case BPF_JMP: @@ -540,18 +581,37 @@ from = i + 1; switch (BPF_OP(p-code)) { case BPF_JA: -if (from + p-k from || from + p-k = len) - return 0; +if (from + p-k = len) + goto out; +#if defined(KERNEL) || defined(_KERNEL) +if (from + p-k from) + goto out; +/* + * mark the currently invalid bits for the + * destination + */ +mem[from + p-k] |= invalid; +invalid = 0; +#endif break; case BPF_JEQ: case BPF_JGT: case BPF_JGE: case BPF_JSET: if (from + p-jt = len || from + p-jf = len) - return 0; + goto out; +#if defined(KERNEL) || defined(_KERNEL) +/* + * mark the currently invalid bits for both + * possible jump destinations + */ +mem[from + p-jt] |= invalid; +mem[from + p-jf] |= invalid; +invalid = 0; +#endif break; default: -return 0; +
CVS commit: [netbsd-5] src/sys/net
Module Name:src Committed By: bouyer Date: Sun Jan 16 13:04:33 UTC 2011 Modified Files: src/sys/net [netbsd-5]: raw_usrreq.c Log Message: Pull up following revision(s) (requested by pooka in ticket #1529): sys/net/raw_usrreq.c: revision 1.36 Apply patch from PR kern/44369 by Wolfgang Stukenbrock. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.35.8.1 src/sys/net/raw_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/net/raw_usrreq.c diff -u src/sys/net/raw_usrreq.c:1.35 src/sys/net/raw_usrreq.c:1.35.8.1 --- src/sys/net/raw_usrreq.c:1.35 Thu May 29 17:26:56 2008 +++ src/sys/net/raw_usrreq.c Sun Jan 16 13:04:33 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: raw_usrreq.c,v 1.35 2008/05/29 17:26:56 dyoung Exp $ */ +/* $NetBSD: raw_usrreq.c,v 1.35.8.1 2011/01/16 13:04:33 bouyer Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: raw_usrreq.c,v 1.35 2008/05/29 17:26:56 dyoung Exp $); +__KERNEL_RCSID(0, $NetBSD: raw_usrreq.c,v 1.35.8.1 2011/01/16 13:04:33 bouyer Exp $); #include sys/param.h #include sys/mbuf.h @@ -276,7 +276,8 @@ /* * stat: don't bother with a blocksize. */ - return (0); + error = 0; + break; /* * Not supported.
CVS commit: [netbsd-5] src/sys/net
Module Name:src Committed By: riz Date: Thu Dec 9 04:11:39 UTC 2010 Modified Files: src/sys/net [netbsd-5]: if_tap.c Log Message: Pull up following revision(s) (requested by christos in ticket #1492): sys/net/if_tap.c: revision 1.66 PR/44131: Matthew Mondor: if_tap.c tap_dev_ioctl() not propagating error, always returns 0. To generate a diff of this commit: cvs rdiff -u -r1.47.4.7 -r1.47.4.8 src/sys/net/if_tap.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/if_tap.c diff -u src/sys/net/if_tap.c:1.47.4.7 src/sys/net/if_tap.c:1.47.4.8 --- src/sys/net/if_tap.c:1.47.4.7 Thu Dec 3 09:40:00 2009 +++ src/sys/net/if_tap.c Thu Dec 9 04:11:39 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: if_tap.c,v 1.47.4.7 2009/12/03 09:40:00 sborrill Exp $ */ +/* $NetBSD: if_tap.c,v 1.47.4.8 2010/12/09 04:11:39 riz Exp $ */ /* * Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation. @@ -33,7 +33,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: if_tap.c,v 1.47.4.7 2009/12/03 09:40:00 sborrill Exp $); +__KERNEL_RCSID(0, $NetBSD: if_tap.c,v 1.47.4.8 2010/12/09 04:11:39 riz Exp $); #if defined(_KERNEL_OPT) #include bpfilter.h @@ -1056,12 +1056,10 @@ static int tap_dev_ioctl(int unit, u_long cmd, void *data, struct lwp *l) { - struct tap_softc *sc = - device_lookup_private(tap_cd, unit); - int error = 0; + struct tap_softc *sc = device_lookup_private(tap_cd, unit); if (sc == NULL) - return (ENXIO); + return ENXIO; switch (cmd) { case FIONREAD: @@ -1078,27 +1076,26 @@ else *(int *)data = m-m_pkthdr.len; splx(s); - } break; + return 0; + } case TIOCSPGRP: case FIOSETOWN: - error = fsetown(sc-sc_pgid, cmd, data); - break; + return fsetown(sc-sc_pgid, cmd, data); case TIOCGPGRP: case FIOGETOWN: - error = fgetown(sc-sc_pgid, cmd, data); - break; + return fgetown(sc-sc_pgid, cmd, data); case FIOASYNC: if (*(int *)data) sc-sc_flags |= TAP_ASYNCIO; else sc-sc_flags = ~TAP_ASYNCIO; - break; + return 0; case FIONBIO: if (*(int *)data) sc-sc_flags |= TAP_NBIO; else sc-sc_flags = ~TAP_NBIO; - break; + return 0; #ifdef OTAPGIFNAME case OTAPGIFNAME: #endif @@ -1108,13 +1105,11 @@ struct ifnet *ifp = sc-sc_ec.ec_if; strlcpy(ifr-ifr_name, ifp-if_xname, IFNAMSIZ); - } break; + return 0; + } default: - error = ENOTTY; - break; + return ENOTTY; } - - return (0); } static int
CVS commit: [netbsd-5] src/sys/net
Module Name:src Committed By: riz Date: Sat Jun 12 16:37:55 UTC 2010 Modified Files: src/sys/net [netbsd-5]: if.c Log Message: Pull up following revision(s) (requested by skrll in ticket #1416): sys/net/if.c: revision 1.244 Correct the argument order of ifreqn2o conversion. Fixes PR/42585. To generate a diff of this commit: cvs rdiff -u -r1.230.4.2 -r1.230.4.3 src/sys/net/if.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/if.c diff -u src/sys/net/if.c:1.230.4.2 src/sys/net/if.c:1.230.4.3 --- src/sys/net/if.c:1.230.4.2 Sat Nov 28 15:47:05 2009 +++ src/sys/net/if.c Sat Jun 12 16:37:55 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: if.c,v 1.230.4.2 2009/11/28 15:47:05 bouyer Exp $ */ +/* $NetBSD: if.c,v 1.230.4.3 2010/06/12 16:37:55 riz Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc. @@ -90,7 +90,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: if.c,v 1.230.4.2 2009/11/28 15:47:05 bouyer Exp $); +__KERNEL_RCSID(0, $NetBSD: if.c,v 1.230.4.3 2010/06/12 16:37:55 riz Exp $); #include opt_inet.h @@ -1713,7 +1713,7 @@ } #ifdef COMPAT_OIFREQ if (cmd != ocmd) - ifreqn2o(oifr, ifr); + ifreqn2o(ifr, oifr); #endif return error;
CVS commit: [netbsd-5] src/sys/net
Module Name:src Committed By: sborrill Date: Thu Dec 3 09:40:00 UTC 2009 Modified Files: src/sys/net [netbsd-5]: if_tap.c Log Message: Pull up the following revisions(s) (requested by plunky in ticket #1173): sys/net/if_tap.c: revision 1.60 Fix a potential leak on tap device close; purging the send queue did not actually release the dequeued mbufs. To generate a diff of this commit: cvs rdiff -u -r1.47.4.6 -r1.47.4.7 src/sys/net/if_tap.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/if_tap.c diff -u src/sys/net/if_tap.c:1.47.4.6 src/sys/net/if_tap.c:1.47.4.7 --- src/sys/net/if_tap.c:1.47.4.6 Sat Apr 4 23:36:28 2009 +++ src/sys/net/if_tap.c Thu Dec 3 09:40:00 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: if_tap.c,v 1.47.4.6 2009/04/04 23:36:28 snj Exp $ */ +/* $NetBSD: if_tap.c,v 1.47.4.7 2009/12/03 09:40:00 sborrill Exp $ */ /* * Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation. @@ -33,7 +33,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: if_tap.c,v 1.47.4.6 2009/04/04 23:36:28 snj Exp $); +__KERNEL_RCSID(0, $NetBSD: if_tap.c,v 1.47.4.7 2009/12/03 09:40:00 sborrill Exp $); #if defined(_KERNEL_OPT) #include bpfilter.h @@ -852,6 +852,7 @@ if (ifp-if_bpf) bpf_mtap(ifp-if_bpf, m); #endif + m_freem(m); } } splx(s);
CVS commit: [netbsd-5] src/sys/net
Module Name:src Committed By: bouyer Date: Sat Nov 28 15:47:05 UTC 2009 Modified Files: src/sys/net [netbsd-5]: if.c Log Message: Pull up following revision(s) (requested by joerg in ticket #1148): sys/net/if.c: revision 1.241 Simplify ifreq_setaddr: - Drop the INET6 block. The commands are never given to this function and truncating the sockaddr is arguably not the desired result anyway. - Clear the address before copying. This fixes SIOCGIFNETMASK and possible other ioctls for users that don't check sa_len. This includes COMPAT_43 and Linux emulation. OK dyoung@ To generate a diff of this commit: cvs rdiff -u -r1.230.4.1 -r1.230.4.2 src/sys/net/if.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/if.c diff -u src/sys/net/if.c:1.230.4.1 src/sys/net/if.c:1.230.4.2 --- src/sys/net/if.c:1.230.4.1 Tue Feb 24 02:26:42 2009 +++ src/sys/net/if.c Sat Nov 28 15:47:05 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: if.c,v 1.230.4.1 2009/02/24 02:26:42 snj Exp $ */ +/* $NetBSD: if.c,v 1.230.4.2 2009/11/28 15:47:05 bouyer Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc. @@ -90,7 +90,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: if.c,v 1.230.4.1 2009/02/24 02:26:42 snj Exp $); +__KERNEL_RCSID(0, $NetBSD: if.c,v 1.230.4.2 2009/11/28 15:47:05 bouyer Exp $); #include opt_inet.h @@ -1816,20 +1816,14 @@ { uint8_t len; u_long ncmd; - const uint8_t osockspace = sizeof(ifr-ifr_addr); - const uint8_t sockspace = sizeof(ifr-ifr_ifru.ifru_space); -#ifdef INET6 - if (cmd == SIOCGIFPSRCADDR_IN6 || cmd == SIOCGIFPDSTADDR_IN6) - len = MIN(sizeof(struct sockaddr_in6), sa-sa_len); - else -#endif /* INET6 */ if ((ncmd = compat_cvtcmd(cmd)) != cmd) - len = MIN(osockspace, sa-sa_len); + len = sizeof(ifr-ifr_addr); else - len = MIN(sockspace, sa-sa_len); + len = sizeof(ifr-ifr_ifru.ifru_space); if (len sa-sa_len) return EFBIG; + memset(ifr-ifr_addr, 0, len); sockaddr_copy(ifr-ifr_addr, len, sa); return 0; }
CVS commit: [netbsd-5] src/sys/net
Module Name:src Committed By: snj Date: Sat Apr 4 18:01:25 UTC 2009 Modified Files: src/sys/net [netbsd-5]: if_bridge.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #660): sys/net/if_bridge.c: revision 1.66 Fixes from Masao Uebayashi To generate a diff of this commit: cvs rdiff -u -r1.62.6.1 -r1.62.6.2 src/sys/net/if_bridge.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/if_bridge.c diff -u src/sys/net/if_bridge.c:1.62.6.1 src/sys/net/if_bridge.c:1.62.6.2 --- src/sys/net/if_bridge.c:1.62.6.1 Sat Apr 4 18:00:03 2009 +++ src/sys/net/if_bridge.c Sat Apr 4 18:01:25 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: if_bridge.c,v 1.62.6.1 2009/04/04 18:00:03 snj Exp $ */ +/* $NetBSD: if_bridge.c,v 1.62.6.2 2009/04/04 18:01:25 snj Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -80,7 +80,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: if_bridge.c,v 1.62.6.1 2009/04/04 18:00:03 snj Exp $); +__KERNEL_RCSID(0, $NetBSD: if_bridge.c,v 1.62.6.2 2009/04/04 18:01:25 snj Exp $); #include opt_bridge_ipf.h #include opt_inet.h @@ -419,8 +419,6 @@ /* Tear down the routing table. */ bridge_rtable_fini(sc); - - softint_disestablish(sc-sc_softintr); free(sc, M_DEVBUF); @@ -1320,10 +1318,13 @@ struct ether_header *eh; int s; - if ((sc-sc_if.if_flags IFF_RUNNING) == 0) + mutex_enter(softnet_lock); + if ((sc-sc_if.if_flags IFF_RUNNING) == 0) { + mutex_exit(softnet_lock); return; + } - s = splbio(); + s = splnet(); while (1) { IFQ_POLL(sc-sc_if.if_snd, m); if (m == NULL) @@ -1444,6 +1445,7 @@ bridge_enqueue(sc, dst_if, m, 1); } splx(s); + mutex_exit(softnet_lock); } /*
CVS commit: [netbsd-5] src/sys/net
Module Name:src Committed By: snj Date: Sat Apr 4 18:02:21 UTC 2009 Modified Files: src/sys/net [netbsd-5]: if_bridge.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #660): sys/net/if_bridge.c: revision 1.67 Fix a comment, and make it build. To generate a diff of this commit: cvs rdiff -u -r1.62.6.2 -r1.62.6.3 src/sys/net/if_bridge.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/if_bridge.c diff -u src/sys/net/if_bridge.c:1.62.6.2 src/sys/net/if_bridge.c:1.62.6.3 --- src/sys/net/if_bridge.c:1.62.6.2 Sat Apr 4 18:01:25 2009 +++ src/sys/net/if_bridge.c Sat Apr 4 18:02:21 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: if_bridge.c,v 1.62.6.2 2009/04/04 18:01:25 snj Exp $ */ +/* $NetBSD: if_bridge.c,v 1.62.6.3 2009/04/04 18:02:21 snj Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -80,7 +80,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: if_bridge.c,v 1.62.6.2 2009/04/04 18:01:25 snj Exp $); +__KERNEL_RCSID(0, $NetBSD: if_bridge.c,v 1.62.6.3 2009/04/04 18:02:21 snj Exp $); #include opt_bridge_ipf.h #include opt_inet.h @@ -92,6 +92,7 @@ #include sys/mbuf.h #include sys/queue.h #include sys/socket.h +#include /sys/socketvar.h /* for softnet_lock */ #include sys/sockio.h #include sys/systm.h #include sys/proc.h @@ -1453,7 +1454,7 @@ * * Receive input from a member interface. Queue the packet for * bridging if it is not for us. - * should be called at splbio() + * should be called at splnet() */ struct mbuf * bridge_input(struct ifnet *ifp, struct mbuf *m)