Source-Changes-HG archive

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

[src/bouyer-socketcan]: src/sys/netcan Centralize mbuf tag cleanup, it will b...



details:   https://anonhg.NetBSD.org/src/rev/364899a1a457
branches:  bouyer-socketcan
changeset: 820823:364899a1a457
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sun Feb 05 11:45:11 2017 +0000

description:
Centralize mbuf tag cleanup, it will be used by real interface drivers too.

diffstat:

 sys/netcan/can.c        |  18 ++++++++++++++++--
 sys/netcan/can_var.h    |   3 ++-
 sys/netcan/if_canloop.c |  13 ++++---------
 3 files changed, 22 insertions(+), 12 deletions(-)

diffs (105 lines):

diff -r e81f5666c9a7 -r 364899a1a457 sys/netcan/can.c
--- a/sys/netcan/can.c  Sun Feb 05 11:44:17 2017 +0000
+++ b/sys/netcan/can.c  Sun Feb 05 11:45:11 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: can.c,v 1.1.2.3 2017/02/05 10:56:12 bouyer Exp $       */
+/*     $NetBSD: can.c,v 1.1.2.4 2017/02/05 11:45:11 bouyer Exp $       */
 
 /*-
  * Copyright (c) 2003, 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: can.c,v 1.1.2.3 2017/02/05 10:56:12 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: can.c,v 1.1.2.4 2017/02/05 11:45:11 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -153,6 +153,20 @@
 }
 
 /*
+ * cleanup mbuf tag, keeping the PACKET_TAG_SO tag
+ */
+void
+can_mbuf_tag_clean(struct mbuf *m)
+{
+       struct m_tag *sotag;
+
+       sotag = m_tag_find(m, PACKET_TAG_SO, NULL);
+       m_tag_delete_nonpersistent(m);
+       if (sotag)
+               m_tag_prepend(m, sotag);
+}
+
+/*
  * Process a received CAN frame
  * the packet is in the mbuf chain m with
  * the CAN header.
diff -r e81f5666c9a7 -r 364899a1a457 sys/netcan/can_var.h
--- a/sys/netcan/can_var.h      Sun Feb 05 11:44:17 2017 +0000
+++ b/sys/netcan/can_var.h      Sun Feb 05 11:45:11 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: can_var.h,v 1.1.2.2 2017/01/16 18:03:38 bouyer Exp $   */
+/*     $NetBSD: can_var.h,v 1.1.2.3 2017/02/05 11:45:11 bouyer Exp $   */
 
 /*-
  * Copyright (c) 2003, 2017 The NetBSD Foundation, Inc.
@@ -45,6 +45,7 @@
 
 extern const struct pr_usrreqs can_usrreqs;
 
+void can_mbuf_tag_clean(struct mbuf *);
 void can_input(struct ifnet *, struct mbuf *);
 void *can_ctlinput(int, struct sockaddr *, void *);
 int can_ctloutput(int, struct socket *, struct sockopt *);
diff -r e81f5666c9a7 -r 364899a1a457 sys/netcan/if_canloop.c
--- a/sys/netcan/if_canloop.c   Sun Feb 05 11:44:17 2017 +0000
+++ b/sys/netcan/if_canloop.c   Sun Feb 05 11:45:11 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_canloop.c,v 1.1.2.2 2017/01/16 18:03:38 bouyer Exp $        */
+/*     $NetBSD: if_canloop.c,v 1.1.2.3 2017/02/05 11:45:11 bouyer Exp $        */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_canloop.c,v 1.1.2.2 2017/01/16 18:03:38 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_canloop.c,v 1.1.2.3 2017/02/05 11:45:11 bouyer Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_can.h"
@@ -83,7 +83,7 @@
 
        /*
         * Nothing to do here, initialization is handled by the
-        * module initialization code in canloopnit() below).
+        * module initialization code in canloopinit() below).
         */
 }
 
@@ -162,7 +162,6 @@
 {
        int error = 0;
        size_t pktlen;
-       struct m_tag *sotag;
 
        MCLAIM(m, ifp->if_mowner);
 
@@ -178,12 +177,8 @@
        ifp->if_opackets++;
        ifp->if_obytes += pktlen;
 
-       /* we have to preserve the socket tag */
-       sotag = m_tag_find(m, PACKET_TAG_SO, NULL);
-       m_tag_delete_nonpersistent(m);
-       if (sotag)
-               m_tag_prepend(m, sotag);
 #ifdef CAN
+       can_mbuf_tag_clean(m);
        can_input(ifp, m);
 #else
        printf("%s: can't handle CAN packet\n", ifp->if_xname);



Home | Main Index | Thread Index | Old Index