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
This commit is contained in:
Gleb Smirnoff 2022-08-11 09:19:36 -07:00
parent b8103ca76d
commit d94ec7490d
2 changed files with 9 additions and 26 deletions

View file

@ -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 {

View file

@ -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 */