On Thu, Aug 08, 2013 at 01:47:17PM +0200, Martin Pieuchot wrote:
> On 08/08/13(Thu) 01:06, Alexander Bluhm wrote:
> > Hi,
> >
> > To control the lifetime of IPv6 addresses, prefixes and default
> > routers, the kernel and ndp use a bunch of expire fields. Currently
> > they are int or long, but expire should always be time_t. Move
> > vltime and pltime to u_int32_t everywhere. Sort struct fields by
> > size. Struct inet6_ndpr_msghdr is not used at all, so remove it.
>
> It looks to me that the in6_oprlist structure is here only for some
> binary compatibility. So changing its fields makes no sense, however
> I think you can completely remove it as it has been introduced in
> 2002 and nothing use the SIOCGPRLST_IN6 ioctl(2) anymore. ;)
We have the code
oprl->prefix[i].expire = pr->ndpr_expire;
in the kernel right now. It is wrong to leave in6_oprlist.prefix->expire
as u_long and ndpr_expire as time_t.
Binary compatibility for ndp will break with this diff anyway and
for most programs with the big time_t diff.
Ndp implements ioctl(s, SIOCGPRLST_IN6, (caddr_t)&pr), but does not
use it because of #ifdef.
I would like to do it this way:
1. fix time_t in all structures with this diff
2. throw away #ifdef in ndp
3. remove obsolete ioctl from kernel
4. remove obsolete struct from header
ok?
bluhm
>
> Apart from that it looks ok to me.
>
> >
> > bluhm
> >
> > Index: netinet6/nd6.h
> > ===================================================================
> > RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/nd6.h,v
> > retrieving revision 1.31
> > diff -u -p -u -p -r1.31 nd6.h
> > --- netinet6/nd6.h 1 Jul 2013 14:22:20 -0000 1.31
> > +++ netinet6/nd6.h 7 Aug 2013 22:54:51 -0000
> > @@ -46,14 +46,14 @@ struct llinfo_nd6 {
> > struct llinfo_nd6 *ln_prev;
> > struct rtentry *ln_rt;
> > struct mbuf *ln_hold; /* last packet until resolved/timeout */
> > - long ln_asked; /* number of queries already sent for this addr
> > */
> > - u_long ln_expire; /* lifetime for NDP state transition */
> > + time_t ln_expire; /* lifetime for NDP state transition */
> > + long ln_asked; /* number of queries already sent for addr */
> > + int ln_byhint; /* # of times we made it reachable by UL hint */
> > short ln_state; /* reachability state */
> > short ln_router; /* 2^0: ND6 router bit */
> > - int ln_byhint; /* # of times we made it reachable by UL hint */
> >
> > long ln_ntick;
> > - struct timeout ln_timer_ch;
> > + struct timeout ln_timer_ch;
> > };
> >
> > #define ND6_LLINFO_PURGE -3
> > @@ -107,10 +107,10 @@ struct nd_ifinfo {
> > struct in6_nbrinfo {
> > char ifname[IFNAMSIZ]; /* if name, e.g. "en0" */
> > struct in6_addr addr; /* IPv6 address of the neighbor */
> > - long asked; /* number of queries already sent for this addr
> > */
> > + time_t expire; /* lifetime for NDP state transition */
> > + long asked; /* number of queries already sent for addr */
> > int isrouter; /* if it acts as a router */
> > int state; /* reachability state */
> > - int expire; /* lifetime for NDP state transition */
> > };
> >
> > #define DRLSTSIZ 10
> > @@ -119,19 +119,19 @@ struct in6_drlist {
> > char ifname[IFNAMSIZ];
> > struct {
> > struct in6_addr rtaddr;
> > - u_char flags;
> > + time_t expire;
> > u_short rtlifetime;
> > - u_long expire;
> > - u_short if_index;
> > + u_short if_index;
> > + u_char flags;
> > } defrouter[DRLSTSIZ];
> > };
> >
> > struct in6_defrouter {
> > struct sockaddr_in6 rtaddr;
> > - u_char flags;
> > + time_t expire;
> > u_short rtlifetime;
> > - u_long expire;
> > - u_short if_index;
> > + u_short if_index;
> > + u_char flags;
> > };
> >
> > #ifdef _KERNEL
> > @@ -139,14 +139,14 @@ struct in6_oprlist {
> > char ifname[IFNAMSIZ];
> > struct {
> > struct in6_addr prefix;
> > - struct prf_ra raflags;
> > + struct prf_ra raflags;
> > + time_t expire;
> > + u_int32_t vltime;
> > + u_int32_t pltime;
> > + u_short if_index;
> > + u_short advrtrs; /* number of advertisement routers */
> > u_char prefixlen;
> > u_char origin;
> > - u_long vltime;
> > - u_long pltime;
> > - u_long expire;
> > - u_short if_index;
> > - u_short advrtrs; /* number of advertisement routers */
> > struct in6_addr advrtr[DRLSTSIZ]; /* XXX: explicit limit */
> > } prefix[PRLSTSIZ];
> > };
> > @@ -156,30 +156,30 @@ struct in6_prlist {
> > char ifname[IFNAMSIZ];
> > struct {
> > struct in6_addr prefix;
> > - struct prf_ra raflags;
> > - u_char prefixlen;
> > - u_char origin;
> > + struct prf_ra raflags;
> > + time_t expire;
> > u_int32_t vltime;
> > u_int32_t pltime;
> > - time_t expire;
> > - u_short if_index;
> > - u_short advrtrs; /* number of advertisement routers */
> > + u_short if_index;
> > + u_short advrtrs; /* number of advertisement routers */
> > + u_char prefixlen;
> > + u_char origin;
> > struct in6_addr advrtr[DRLSTSIZ]; /* XXX: explicit limit */
> > } prefix[PRLSTSIZ];
> > };
> >
> > struct in6_prefix {
> > struct sockaddr_in6 prefix;
> > - struct prf_ra raflags;
> > - u_char prefixlen;
> > - u_char origin;
> > + struct prf_ra raflags;
> > + time_t expire;
> > u_int32_t vltime;
> > u_int32_t pltime;
> > - time_t expire;
> > u_int32_t flags;
> > - int refcnt;
> > - u_short if_index;
> > - u_short advrtrs; /* number of advertisement routers */
> > + int refcnt;
> > + u_short if_index;
> > + u_short advrtrs; /* number of advertisement routers */
> > + u_char prefixlen;
> > + u_char origin;
> > /* struct sockaddr_in6 advrtr[] */
> > };
> >
> > @@ -242,11 +242,11 @@ TAILQ_HEAD(nd_drhead, nd_defrouter);
> > struct nd_defrouter {
> > TAILQ_ENTRY(nd_defrouter) dr_entry;
> > struct in6_addr rtaddr;
> > - u_char flags; /* flags on RA message */
> > - u_short rtlifetime;
> > - u_long expire;
> > struct ifnet *ifp;
> > + time_t expire;
> > int installed; /* is installed into kernel routing table */
> > + u_short rtlifetime;
> > + u_char flags; /* flags on RA message */
> > };
> >
> > struct nd_prefix {
> > @@ -255,13 +255,13 @@ struct nd_prefix {
> > struct sockaddr_in6 ndpr_prefix; /* prefix */
> > struct in6_addr ndpr_mask; /* netmask derived from the prefix */
> >
> > - u_int32_t ndpr_vltime; /* advertised valid lifetime */
> > - u_int32_t ndpr_pltime; /* advertised preferred lifetime */
> > -
> > time_t ndpr_expire; /* expiration time of the prefix */
> > time_t ndpr_preferred; /* preferred time of the prefix */
> > time_t ndpr_lastupdate; /* reception time of last advertisement */
> >
> > + u_int32_t ndpr_vltime; /* advertised valid lifetime */
> > + u_int32_t ndpr_pltime; /* advertised preferred lifetime */
> > +
> > struct prf_ra ndpr_flags;
> > u_int32_t ndpr_stateflags; /* actual state flags */
> > /* list of routers that advertise the prefix: */
> > @@ -274,32 +274,6 @@ struct nd_prefix {
> > #define ndpr_raf_onlink ndpr_flags.onlink
> > #define ndpr_raf_auto ndpr_flags.autonomous
> > #define ndpr_raf_router ndpr_flags.router
> > -
> > -/*
> > - * Message format for use in obtaining information about prefixes
> > - * from inet6 sysctl function
> > - */
> > -struct inet6_ndpr_msghdr {
> > - u_short inpm_msglen; /* to skip over non-understood messages */
> > - u_char inpm_version; /* future binary compatibility */
> > - u_char inpm_type; /* message type */
> > - struct in6_addr inpm_prefix;
> > - u_long prm_vltim;
> > - u_long prm_pltime;
> > - u_long prm_expire;
> > - u_long prm_preferred;
> > - struct in6_prflags prm_flags;
> > - u_short prm_index; /* index for associated ifp */
> > - u_char prm_plen; /* length of prefix in bits */
> > -};
> > -
> > -#define prm_raf_onlink prm_flags.prf_ra.onlink
> > -#define prm_raf_auto prm_flags.prf_ra.autonomous
> > -
> > -#define prm_statef_onlink prm_flags.prf_state.onlink
> > -
> > -#define prm_rrf_decrvalid prm_flags.prf_rr.decrvalid
> > -#define prm_rrf_decrprefd prm_flags.prf_rr.decrprefd
> >
> > struct nd_pfxrouter {
> > LIST_ENTRY(nd_pfxrouter) pfr_entry;
> >