Module Name: src Committed By: bouyer Date: Sun Feb 5 11:45:11 UTC 2017
Modified Files: src/sys/netcan [bouyer-socketcan]: can.c can_var.h if_canloop.c Log Message: Centralize mbuf tag cleanup, it will be used by real interface drivers too. To generate a diff of this commit: cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/netcan/can.c cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/netcan/can_var.h \ src/sys/netcan/if_canloop.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/netcan/can.c diff -u src/sys/netcan/can.c:1.1.2.3 src/sys/netcan/can.c:1.1.2.4 --- src/sys/netcan/can.c:1.1.2.3 Sun Feb 5 10:56:12 2017 +++ src/sys/netcan/can.c Sun Feb 5 11:45:11 2017 @@ -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 @@ bad: } /* + * 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. Index: src/sys/netcan/can_var.h diff -u src/sys/netcan/can_var.h:1.1.2.2 src/sys/netcan/can_var.h:1.1.2.3 --- src/sys/netcan/can_var.h:1.1.2.2 Mon Jan 16 18:03:38 2017 +++ src/sys/netcan/can_var.h Sun Feb 5 11:45:11 2017 @@ -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 struct domain candomain; 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 *); Index: src/sys/netcan/if_canloop.c diff -u src/sys/netcan/if_canloop.c:1.1.2.2 src/sys/netcan/if_canloop.c:1.1.2.3 --- src/sys/netcan/if_canloop.c:1.1.2.2 Mon Jan 16 18:03:38 2017 +++ src/sys/netcan/if_canloop.c Sun Feb 5 11:45:11 2017 @@ -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 @@ canloopattach(int n) /* * 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 @@ canloop_output(struct ifnet *ifp, struct { int error = 0; size_t pktlen; - struct m_tag *sotag; MCLAIM(m, ifp->if_mowner); @@ -178,12 +177,8 @@ canloop_output(struct ifnet *ifp, struct 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);