The branch main has been updated by glebius:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d94ec7490d3182ef3ad0b572acf0feb9c0a6827f

commit d94ec7490d3182ef3ad0b572acf0feb9c0a6827f
Author:     Gleb Smirnoff <gleb...@freebsd.org>
AuthorDate: 2022-08-11 16:19:36 +0000
Commit:     Gleb Smirnoff <gleb...@freebsd.org>
CommitDate: 2022-08-11 16:19:36 +0000

    rtsock: do not allocate mbufs_tags(9) just to store a 8-bit value
    
    Use local storage of the mbuf packet header instead.
    
    Reviewed by:            melifaro
    Differential revision:  https://reviews.freebsd.org/D36121
---
 sys/net/rtsock.c | 33 ++++++++-------------------------
 sys/sys/mbuf.h   |  2 +-
 2 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index cbec7d351bd5..837491a3821b 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -154,6 +154,10 @@ int        (*carp_get_vhid_p)(struct ifaddr *);
  * notification to a socket bound to a particular FIB.
  */
 #define        RTS_FILTER_FIB  M_PROTO8
+/*
+ * Used to store address family of the notification.
+ */
+#define        m_rtsock_family m_pkthdr.PH_loc.eight[0]
 
 typedef struct {
        int     ip_count;       /* attached w/ AF_INET */
@@ -292,17 +296,9 @@ static void
 rts_input(struct mbuf *m)
 {
        struct sockproto route_proto;
-       unsigned short *family;
-       struct m_tag *tag;
 
        route_proto.sp_family = PF_ROUTE;
-       tag = m_tag_find(m, PACKET_TAG_RTSOCKFAM, NULL);
-       if (tag != NULL) {
-               family = (unsigned short *)(tag + 1);
-               route_proto.sp_protocol = *family;
-               m_tag_delete(m, tag);
-       } else
-               route_proto.sp_protocol = 0;
+       route_proto.sp_protocol = m->m_rtsock_family;
 
        raw_input_ext(m, &route_proto, &route_src, raw_input_rts_cb);
 }
@@ -2183,23 +2179,10 @@ rt_ifannouncemsg(struct ifnet *ifp, int what)
 static void
 rt_dispatch(struct mbuf *m, sa_family_t saf)
 {
-       struct m_tag *tag;
 
-       /*
-        * Preserve the family from the sockaddr, if any, in an m_tag for
-        * use when injecting the mbuf into the routing socket buffer from
-        * the netisr.
-        */
-       if (saf != AF_UNSPEC) {
-               tag = m_tag_get(PACKET_TAG_RTSOCKFAM, sizeof(unsigned short),
-                   M_NOWAIT);
-               if (tag == NULL) {
-                       m_freem(m);
-                       return;
-               }
-               *(unsigned short *)(tag + 1) = saf;
-               m_tag_prepend(m, tag);
-       }
+       M_ASSERTPKTHDR(m);
+
+       m->m_rtsock_family = saf;
        if (V_loif)
                m->m_pkthdr.rcvif = V_loif;
        else {
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index 48ed63ef67b8..9e50a640eac0 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -1385,7 +1385,7 @@ extern bool               mb_use_ext_pgs; /* Use ext_pgs 
for sendfile */
 #define        PACKET_TAG_IPFORWARD                    18 /* ipforward info */
 #define        PACKET_TAG_MACLABEL     (19 | MTAG_PERSISTENT) /* MAC label */
 #define        PACKET_TAG_PF                           21 /* PF/ALTQ 
information */
-#define        PACKET_TAG_RTSOCKFAM                    25 /* rtsock sa family 
*/
+/* was PACKET_TAG_RTSOCKFAM                    25    rtsock sa family */
 #define        PACKET_TAG_IPOPTIONS                    27 /* Saved IP options 
*/
 #define        PACKET_TAG_CARP                         28 /* CARP info */
 #define        PACKET_TAG_IPSEC_NAT_T_PORTS            29 /* two uint16_t */

Reply via email to