Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-10]: src/sys/net Pull up following revision(s) (requested by gutt...



details:   https://anonhg.NetBSD.org/src/rev/ca2617c274b4
branches:  netbsd-10
changeset: 373688:ca2617c274b4
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Feb 24 13:10:53 2023 +0000

description:
Pull up following revision(s) (requested by gutteridge in ticket #103):

        sys/net/bpf.c: revision 1.251

bpf.c: support loopback writes when BIOCSHDRCMPLT is set

Following changes in r. 1.249 "bpf: support sending packets on loopback
interfaces", also allow for this to succeed when the "header complete"
flag is set, which is the practice of some tools, e.g., tcpreplay and
Scapy. With this change, both of those example tools now work, e.g.,
Scapy passes "L3bpfSocket - send and sniff on loopback" in its test
suite.

There are several ways of addressing this issue; this commit is
intended to be the most conservative and consistent with the previous
changes. (E.g., FreeBSD instead has special handling of this condition
in its if_loop.c.)

diffstat:

 sys/net/bpf.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (32 lines):

diff -r a5100783692e -r ca2617c274b4 sys/net/bpf.c
--- a/sys/net/bpf.c     Fri Feb 24 13:05:24 2023 +0000
+++ b/sys/net/bpf.c     Fri Feb 24 13:10:53 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bpf.c,v 1.249 2022/11/30 06:02:37 ozaki-r Exp $        */
+/*     $NetBSD: bpf.c,v 1.249.2.1 2023/02/24 13:10:53 martin Exp $     */
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.249 2022/11/30 06:02:37 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.249.2.1 2023/02/24 13:10:53 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -876,7 +876,12 @@
                goto out;
        }
 
-       if (d->bd_hdrcmplt)
+       /*
+        * If writing to a loopback interface, the address family has
+        * already been specially computed in bpf_movein(), so don't
+        * clobber it, or the loopback will reject it in looutput().
+        */
+       if (d->bd_hdrcmplt && ifp->if_type != IFT_LOOP)
                dst.ss_family = pseudo_AF_HDRCMPLT;
 
        if (d->bd_feedback) {



Home | Main Index | Thread Index | Old Index