Source-Changes-HG archive

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

[src/trunk]: src/sys net: Store a pointer to the Layer 2 Sender Hardware addr...



details:   https://anonhg.NetBSD.org/src/rev/22629aefeb0d
branches:  trunk
changeset: 372319:22629aefeb0d
user:      roy <roy%NetBSD.org@localhost>
date:      Mon Nov 14 09:23:42 2022 +0000

description:
net: Store a pointer to the Layer 2 Sender Hardware address in mbuf

The BSD networking stack is designed around passing a mbuf down the chain
and each layer removes the part it's interested in before passing it to
the next. This makes it easy for each layer to do it's work,
but non trivial to work backwards.

As such we now store a pointer to the Senders Hardware address in the
mbuf packet header so that protocols can perform any required validation.

diffstat:

 sys/net/if_ethersubr.c |  8 ++++++--
 sys/sys/mbuf.h         |  5 ++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diffs (48 lines):

diff -r e7e955464d21 -r 22629aefeb0d sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Sun Nov 13 21:57:12 2022 +0000
+++ b/sys/net/if_ethersubr.c    Mon Nov 14 09:23:42 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ethersubr.c,v 1.320 2022/09/03 02:47:59 thorpej Exp $       */
+/*     $NetBSD: if_ethersubr.c,v 1.321 2022/11/14 09:23:42 roy Exp $   */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.320 2022/09/03 02:47:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.321 2022/11/14 09:23:42 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -886,6 +886,10 @@
 #endif
        }
 
+       /* Store the senders hardware address */
+       m->m_pkthdr.l2_sha = &eh->ether_shost;
+       m->m_pkthdr.l2_shalen = ETHER_ADDR_LEN;
+
        /* Strip off the Ethernet header. */
        m_adj(m, ehlen);
 
diff -r e7e955464d21 -r 22629aefeb0d sys/sys/mbuf.h
--- a/sys/sys/mbuf.h    Sun Nov 13 21:57:12 2022 +0000
+++ b/sys/sys/mbuf.h    Mon Nov 14 09:23:42 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mbuf.h,v 1.232 2021/02/19 14:51:59 christos Exp $      */
+/*     $NetBSD: mbuf.h,v 1.233 2022/11/14 09:23:42 roy Exp $   */
 
 /*
  * Copyright (c) 1996, 1997, 1999, 2001, 2007 The NetBSD Foundation, Inc.
@@ -203,6 +203,9 @@
        int     pattr_af;               /* ALTQ: address family */
        void    *pattr_class;           /* ALTQ: sched class set by classifier */
        void    *pattr_hdr;             /* ALTQ: saved header position in mbuf */
+
+       void            *l2_sha;                /* l2 sender host address */
+       size_t          l2_shalen;              /* length of the sender address */
 };
 
 /* Checksumming flags (csum_flags). */



Home | Main Index | Thread Index | Old Index