From 5bda38b8a563426e9cc297677f8788b7eab12d04 Mon Sep 17 00:00:00 2001 From: bluhm Date: Fri, 19 Apr 2024 10:13:58 +0000 Subject: [PATCH] Merge IPv4 and IPv6 options in inpcb. A internet PCB has either inp_options or inp_outputopts6. Put them into a common anonymous union. OK mvs@ kn@ --- sys/netinet/in_pcb.c | 7 ++++--- sys/netinet/in_pcb.h | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 958d8ea9be9..1a6bc7166ec 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.301 2024/04/17 20:48:51 bluhm Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.302 2024/04/19 10:13:58 bluhm Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -592,7 +592,6 @@ in_pcbdetach(struct inpcb *inp) * points. */ sofree(so, 1); - m_freem(inp->inp_options); if (inp->inp_route.ro_rt) { rtfree(inp->inp_route.ro_rt); inp->inp_route.ro_rt = NULL; @@ -603,8 +602,10 @@ in_pcbdetach(struct inpcb *inp) ip6_freemoptions(inp->inp_moptions6); } else #endif + { + m_freem(inp->inp_options); ip_freemoptions(inp->inp_moptions); - + } #if NPF > 0 pf_remove_divert_state(inp); pf_inp_unlink(inp); diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 60b3ae537e0..6e0b656b19f 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.h,v 1.156 2024/04/17 20:48:51 bluhm Exp $ */ +/* $OpenBSD: in_pcb.h,v 1.157 2024/04/19 10:13:58 bluhm Exp $ */ /* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */ /* @@ -157,8 +157,10 @@ struct inpcb { } inp_hu; #define inp_ip inp_hu.hu_ip #define inp_ipv6 inp_hu.hu_ipv6 - struct mbuf *inp_options; /* IP options */ - struct ip6_pktopts *inp_outputopts6; /* IP6 options for outgoing packets */ + union { + struct mbuf *inp_options; /* IPv4 options */ + struct ip6_pktopts *inp_outputopts6; /* IPv6 options */ + }; int inp_hops; union { struct ip_moptions *mou_mo; -- 2.20.1