From: Vitaliy Makkoveev Subject: Re: inpcb options To: Alexander Bluhm Cc: tech@openbsd.org Date: Wed, 17 Apr 2024 18:40:41 +0300 On Tue, Apr 16, 2024 at 08:29:00PM +0200, Alexander Bluhm wrote: > Hi, > > A internet PCB has either IPv4 or IPv6 options. We can put them > in a common anonymous union. > > ok? > ok mvs > bluhm > > Index: netinet/in_pcb.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/in_pcb.c,v > diff -u -p -r1.300 in_pcb.c > --- netinet/in_pcb.c 12 Apr 2024 16:07:09 -0000 1.300 > +++ netinet/in_pcb.c 16 Apr 2024 18:15:58 -0000 > @@ -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); > Index: netinet/in_pcb.h > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/in_pcb.h,v > diff -u -p -r1.155 in_pcb.h > --- netinet/in_pcb.h 15 Apr 2024 18:31:04 -0000 1.155 > +++ netinet/in_pcb.h 16 Apr 2024 18:15:58 -0000 > @@ -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; >