Re: Kill deprecated IPv6 ioctl(2)s

2017-10-26 Thread Jonathan Gray
On Wed, Oct 25, 2017 at 12:20:45PM +0200, Martin Pieuchot wrote:
> Diff below remove some more deprecated ioctl(2).  The first group below
> correspond to features now deprecated by slaacd(8):
> 
>   SIOCSIFINFO_FLAGS, SIOCSNDFLUSH_IN6, SIOCSPFXFLUSH_IN6, SIOCSRTRFLUSH_IN6
> 
> Removing those might break some ports.  This is good!  Because now they
> are broken at compile time and can be fixed.  Currently they might or
> might not work.  On codesearch.debian.net only dhcpcd5 seems to try to use
> them.
> 
> The second group of ioctl(2)s is not used in base and should be used
> conditionally in ports, so it should be safe:
>   SIOCGIFADDR_IN6, SIOCGIFSTAT_IN6, SIOCGIFSTAT_ICMP6
> 
> Diff below also move some define around in netinet6/in6_var.h to reduce
> the number of #ifdef _KERNEL chunks.
> 
> ok?

ok jsg@

> 
> Index: netinet6/in6.c
> ===
> RCS file: /cvs/src/sys/netinet6/in6.c,v
> retrieving revision 1.215
> diff -u -p -r1.215 in6.c
> --- netinet6/in6.c24 Oct 2017 09:30:15 -  1.215
> +++ netinet6/in6.c25 Oct 2017 10:06:05 -
> @@ -213,13 +213,6 @@ in6_ioctl(u_long cmd, caddr_t data, stru
>   return (EOPNOTSUPP);
>  
>   switch (cmd) {
> - case SIOCSNDFLUSH_IN6:
> - case SIOCSPFXFLUSH_IN6:
> - case SIOCSRTRFLUSH_IN6:
> - case SIOCSIFINFO_FLAGS:
> - if (!privileged)
> - return (EPERM);
> - /* FALLTHROUGH */
>   case SIOCGIFINFO_IN6:
>   case SIOCGNBRINFO_IN6:
>   return (nd6_ioctl(cmd, data, ifp));
> @@ -241,17 +234,11 @@ in6_ioctl(u_long cmd, caddr_t data, stru
>   case SIOCAIFADDR_IN6:
>   sa6 = >ifra_addr;
>   break;
> - case SIOCGIFADDR_IN6:
>   case SIOCGIFDSTADDR_IN6:
>   case SIOCGIFNETMASK_IN6:
>   case SIOCDIFADDR_IN6:
>   case SIOCGIFAFLAG_IN6:
> - case SIOCSNDFLUSH_IN6:
> - case SIOCSPFXFLUSH_IN6:
> - case SIOCSRTRFLUSH_IN6:
>   case SIOCGIFALIFETIME_IN6:
> - case SIOCGIFSTAT_IN6:
> - case SIOCGIFSTAT_ICMP6:
>   sa6 = >ifr_addr;
>   break;
>   case SIOCSIFADDR:
> @@ -313,9 +300,6 @@ in6_ioctl(u_long cmd, caddr_t data, stru
>  
>   break;
>  
> - case SIOCGIFADDR_IN6:
> - /* This interface is basically deprecated. use SIOCGIFCONF. */
> - /* FALLTHROUGH */
>   case SIOCGIFAFLAG_IN6:
>   case SIOCGIFNETMASK_IN6:
>   case SIOCGIFDSTADDR_IN6:
> @@ -328,10 +312,6 @@ in6_ioctl(u_long cmd, caddr_t data, stru
>  
>   switch (cmd) {
>  
> - case SIOCGIFADDR_IN6:
> - ifr->ifr_addr = ia6->ia_addr;
> - break;
> -
>   case SIOCGIFDSTADDR_IN6:
>   if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
>   return (EINVAL);
> @@ -349,10 +329,6 @@ in6_ioctl(u_long cmd, caddr_t data, stru
>   case SIOCGIFAFLAG_IN6:
>   ifr->ifr_ifru.ifru_flags6 = ia6->ia6_flags;
>   break;
> -
> - case SIOCGIFSTAT_IN6:
> - case SIOCGIFSTAT_ICMP6:
> - return (EOPNOTSUPP);
>  
>   case SIOCGIFALIFETIME_IN6:
>   ifr->ifr_ifru.ifru_lifetime = ia6->ia6_lifetime;
> Index: netinet6/in6_var.h
> ===
> RCS file: /cvs/src/sys/netinet6/in6_var.h,v
> retrieving revision 1.70
> diff -u -p -r1.70 in6_var.h
> --- netinet6/in6_var.h24 Oct 2017 09:36:13 -  1.70
> +++ netinet6/in6_var.h25 Oct 2017 10:06:05 -
> @@ -278,40 +278,21 @@ struct  in6_aliasreq {
>  #define IFA_IN6(x)   (&((struct sockaddr_in6 *)((x)->ifa_addr))->sin6_addr)
>  #define IFA_DSTIN6(x)(&((struct sockaddr_in6 
> *)((x)->ifa_dstaddr))->sin6_addr)
>  
> -#ifdef _KERNEL
> -#define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m)   (   \
> - (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \
> - (((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \
> - (((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \
> - (((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 )
> -#endif /* _KERNEL */
> -
> -#define SIOCGIFADDR_IN6  _IOWR('i', 33, struct in6_ifreq)
> +#define SIOCDIFADDR_IN6   _IOW('i', 25, struct in6_ifreq)
> +#define SIOCAIFADDR_IN6   _IOW('i', 26, struct in6_aliasreq)
>  
>  #define SIOCGIFDSTADDR_IN6   _IOWR('i', 34, struct in6_ifreq)
>  #define SIOCGIFNETMASK_IN6   _IOWR('i', 37, struct in6_ifreq)
>  
> -#define SIOCDIFADDR_IN6   _IOW('i', 25, struct in6_ifreq)
> -#define SIOCAIFADDR_IN6   _IOW('i', 26, struct in6_aliasreq)
> -
>  #define SIOCGIFAFLAG_IN6 _IOWR('i', 73, struct in6_ifreq)
>  
>  #define SIOCGIFINFO_IN6  _IOWR('i', 108, struct in6_ndireq)
> -#define SIOCSNDFLUSH_IN6 _IOWR('i', 77, struct in6_ifreq)
>  #define SIOCGNBRINFO_IN6 _IOWR('i', 78, struct in6_nbrinfo)

Re: Kill deprecated IPv6 ioctl(2)s

2017-10-25 Thread Florian Obser
OK florian@

On Wed, Oct 25, 2017 at 10:20:45AM +, Martin Pieuchot wrote:
> Diff below remove some more deprecated ioctl(2).  The first group below
> correspond to features now deprecated by slaacd(8):
> 
>   SIOCSIFINFO_FLAGS, SIOCSNDFLUSH_IN6, SIOCSPFXFLUSH_IN6, SIOCSRTRFLUSH_IN6
> 
> Removing those might break some ports.  This is good!  Because now they
> are broken at compile time and can be fixed.  Currently they might or
> might not work.  On codesearch.debian.net only dhcpcd5 seems to try to use
> them.
> 
> The second group of ioctl(2)s is not used in base and should be used
> conditionally in ports, so it should be safe:
>   SIOCGIFADDR_IN6, SIOCGIFSTAT_IN6, SIOCGIFSTAT_ICMP6
> 
> Diff below also move some define around in netinet6/in6_var.h to reduce
> the number of #ifdef _KERNEL chunks.
> 
> ok?
> 
> Index: netinet6/in6.c
> ===
> RCS file: /cvs/src/sys/netinet6/in6.c,v
> retrieving revision 1.215
> diff -u -p -r1.215 in6.c
> --- netinet6/in6.c24 Oct 2017 09:30:15 -  1.215
> +++ netinet6/in6.c25 Oct 2017 10:06:05 -
> @@ -213,13 +213,6 @@ in6_ioctl(u_long cmd, caddr_t data, stru
>   return (EOPNOTSUPP);
>  
>   switch (cmd) {
> - case SIOCSNDFLUSH_IN6:
> - case SIOCSPFXFLUSH_IN6:
> - case SIOCSRTRFLUSH_IN6:
> - case SIOCSIFINFO_FLAGS:
> - if (!privileged)
> - return (EPERM);
> - /* FALLTHROUGH */
>   case SIOCGIFINFO_IN6:
>   case SIOCGNBRINFO_IN6:
>   return (nd6_ioctl(cmd, data, ifp));
> @@ -241,17 +234,11 @@ in6_ioctl(u_long cmd, caddr_t data, stru
>   case SIOCAIFADDR_IN6:
>   sa6 = >ifra_addr;
>   break;
> - case SIOCGIFADDR_IN6:
>   case SIOCGIFDSTADDR_IN6:
>   case SIOCGIFNETMASK_IN6:
>   case SIOCDIFADDR_IN6:
>   case SIOCGIFAFLAG_IN6:
> - case SIOCSNDFLUSH_IN6:
> - case SIOCSPFXFLUSH_IN6:
> - case SIOCSRTRFLUSH_IN6:
>   case SIOCGIFALIFETIME_IN6:
> - case SIOCGIFSTAT_IN6:
> - case SIOCGIFSTAT_ICMP6:
>   sa6 = >ifr_addr;
>   break;
>   case SIOCSIFADDR:
> @@ -313,9 +300,6 @@ in6_ioctl(u_long cmd, caddr_t data, stru
>  
>   break;
>  
> - case SIOCGIFADDR_IN6:
> - /* This interface is basically deprecated. use SIOCGIFCONF. */
> - /* FALLTHROUGH */
>   case SIOCGIFAFLAG_IN6:
>   case SIOCGIFNETMASK_IN6:
>   case SIOCGIFDSTADDR_IN6:
> @@ -328,10 +312,6 @@ in6_ioctl(u_long cmd, caddr_t data, stru
>  
>   switch (cmd) {
>  
> - case SIOCGIFADDR_IN6:
> - ifr->ifr_addr = ia6->ia_addr;
> - break;
> -
>   case SIOCGIFDSTADDR_IN6:
>   if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
>   return (EINVAL);
> @@ -349,10 +329,6 @@ in6_ioctl(u_long cmd, caddr_t data, stru
>   case SIOCGIFAFLAG_IN6:
>   ifr->ifr_ifru.ifru_flags6 = ia6->ia6_flags;
>   break;
> -
> - case SIOCGIFSTAT_IN6:
> - case SIOCGIFSTAT_ICMP6:
> - return (EOPNOTSUPP);
>  
>   case SIOCGIFALIFETIME_IN6:
>   ifr->ifr_ifru.ifru_lifetime = ia6->ia6_lifetime;
> Index: netinet6/in6_var.h
> ===
> RCS file: /cvs/src/sys/netinet6/in6_var.h,v
> retrieving revision 1.70
> diff -u -p -r1.70 in6_var.h
> --- netinet6/in6_var.h24 Oct 2017 09:36:13 -  1.70
> +++ netinet6/in6_var.h25 Oct 2017 10:06:05 -
> @@ -278,40 +278,21 @@ struct  in6_aliasreq {
>  #define IFA_IN6(x)   (&((struct sockaddr_in6 *)((x)->ifa_addr))->sin6_addr)
>  #define IFA_DSTIN6(x)(&((struct sockaddr_in6 
> *)((x)->ifa_dstaddr))->sin6_addr)
>  
> -#ifdef _KERNEL
> -#define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m)   (   \
> - (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \
> - (((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \
> - (((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \
> - (((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 )
> -#endif /* _KERNEL */
> -
> -#define SIOCGIFADDR_IN6  _IOWR('i', 33, struct in6_ifreq)
> +#define SIOCDIFADDR_IN6   _IOW('i', 25, struct in6_ifreq)
> +#define SIOCAIFADDR_IN6   _IOW('i', 26, struct in6_aliasreq)
>  
>  #define SIOCGIFDSTADDR_IN6   _IOWR('i', 34, struct in6_ifreq)
>  #define SIOCGIFNETMASK_IN6   _IOWR('i', 37, struct in6_ifreq)
>  
> -#define SIOCDIFADDR_IN6   _IOW('i', 25, struct in6_ifreq)
> -#define SIOCAIFADDR_IN6   _IOW('i', 26, struct in6_aliasreq)
> -
>  #define SIOCGIFAFLAG_IN6 _IOWR('i', 73, struct in6_ifreq)
>  
>  #define SIOCGIFINFO_IN6  _IOWR('i', 108, struct in6_ndireq)
> -#define SIOCSNDFLUSH_IN6 _IOWR('i', 77, struct in6_ifreq)
>  #define SIOCGNBRINFO_IN6 _IOWR('i', 78, struct 

Re: Kill deprecated IPv6 ioctl(2)s

2017-10-25 Thread Martin Pieuchot
On 25/10/17(Wed) 14:17, Stuart Henderson wrote:
> On 2017/10/25 12:20, Martin Pieuchot wrote:
> > The second group of ioctl(2)s is not used in base and should be used
> > conditionally in ports, so it should be safe:
> >   SIOCGIFADDR_IN6, SIOCGIFSTAT_IN6, SIOCGIFSTAT_ICMP6
> 
> "should" :-) Net-SNMP uses SIOCGIFSTAT_IN6 without a guard in
> 
> agent/mibgroup/ip-mib/data_access/systemstats_sysctl.c:_systemstats_v6_load_ifstats()

This is inside #ifdef __NetBSD__, the port builds fine for me.



Re: Kill deprecated IPv6 ioctl(2)s

2017-10-25 Thread Stuart Henderson
On 2017/10/25 12:20, Martin Pieuchot wrote:
> The second group of ioctl(2)s is not used in base and should be used
> conditionally in ports, so it should be safe:
>   SIOCGIFADDR_IN6, SIOCGIFSTAT_IN6, SIOCGIFSTAT_ICMP6

"should" :-) Net-SNMP uses SIOCGIFSTAT_IN6 without a guard in

agent/mibgroup/ip-mib/data_access/systemstats_sysctl.c:_systemstats_v6_load_ifstats()

Sorry ENOTIME to look right now.


> Diff below also move some define around in netinet6/in6_var.h to reduce
> the number of #ifdef _KERNEL chunks.
> 
> ok?
> 
> Index: netinet6/in6.c
> ===
> RCS file: /cvs/src/sys/netinet6/in6.c,v
> retrieving revision 1.215
> diff -u -p -r1.215 in6.c
> --- netinet6/in6.c24 Oct 2017 09:30:15 -  1.215
> +++ netinet6/in6.c25 Oct 2017 10:06:05 -
> @@ -213,13 +213,6 @@ in6_ioctl(u_long cmd, caddr_t data, stru
>   return (EOPNOTSUPP);
>  
>   switch (cmd) {
> - case SIOCSNDFLUSH_IN6:
> - case SIOCSPFXFLUSH_IN6:
> - case SIOCSRTRFLUSH_IN6:
> - case SIOCSIFINFO_FLAGS:
> - if (!privileged)
> - return (EPERM);
> - /* FALLTHROUGH */
>   case SIOCGIFINFO_IN6:
>   case SIOCGNBRINFO_IN6:
>   return (nd6_ioctl(cmd, data, ifp));
> @@ -241,17 +234,11 @@ in6_ioctl(u_long cmd, caddr_t data, stru
>   case SIOCAIFADDR_IN6:
>   sa6 = >ifra_addr;
>   break;
> - case SIOCGIFADDR_IN6:
>   case SIOCGIFDSTADDR_IN6:
>   case SIOCGIFNETMASK_IN6:
>   case SIOCDIFADDR_IN6:
>   case SIOCGIFAFLAG_IN6:
> - case SIOCSNDFLUSH_IN6:
> - case SIOCSPFXFLUSH_IN6:
> - case SIOCSRTRFLUSH_IN6:
>   case SIOCGIFALIFETIME_IN6:
> - case SIOCGIFSTAT_IN6:
> - case SIOCGIFSTAT_ICMP6:
>   sa6 = >ifr_addr;
>   break;
>   case SIOCSIFADDR:
> @@ -313,9 +300,6 @@ in6_ioctl(u_long cmd, caddr_t data, stru
>  
>   break;
>  
> - case SIOCGIFADDR_IN6:
> - /* This interface is basically deprecated. use SIOCGIFCONF. */
> - /* FALLTHROUGH */
>   case SIOCGIFAFLAG_IN6:
>   case SIOCGIFNETMASK_IN6:
>   case SIOCGIFDSTADDR_IN6:
> @@ -328,10 +312,6 @@ in6_ioctl(u_long cmd, caddr_t data, stru
>  
>   switch (cmd) {
>  
> - case SIOCGIFADDR_IN6:
> - ifr->ifr_addr = ia6->ia_addr;
> - break;
> -
>   case SIOCGIFDSTADDR_IN6:
>   if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
>   return (EINVAL);
> @@ -349,10 +329,6 @@ in6_ioctl(u_long cmd, caddr_t data, stru
>   case SIOCGIFAFLAG_IN6:
>   ifr->ifr_ifru.ifru_flags6 = ia6->ia6_flags;
>   break;
> -
> - case SIOCGIFSTAT_IN6:
> - case SIOCGIFSTAT_ICMP6:
> - return (EOPNOTSUPP);
>  
>   case SIOCGIFALIFETIME_IN6:
>   ifr->ifr_ifru.ifru_lifetime = ia6->ia6_lifetime;
> Index: netinet6/in6_var.h
> ===
> RCS file: /cvs/src/sys/netinet6/in6_var.h,v
> retrieving revision 1.70
> diff -u -p -r1.70 in6_var.h
> --- netinet6/in6_var.h24 Oct 2017 09:36:13 -  1.70
> +++ netinet6/in6_var.h25 Oct 2017 10:06:05 -
> @@ -278,40 +278,21 @@ struct  in6_aliasreq {
>  #define IFA_IN6(x)   (&((struct sockaddr_in6 *)((x)->ifa_addr))->sin6_addr)
>  #define IFA_DSTIN6(x)(&((struct sockaddr_in6 
> *)((x)->ifa_dstaddr))->sin6_addr)
>  
> -#ifdef _KERNEL
> -#define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m)   (   \
> - (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \
> - (((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \
> - (((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \
> - (((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 )
> -#endif /* _KERNEL */
> -
> -#define SIOCGIFADDR_IN6  _IOWR('i', 33, struct in6_ifreq)
> +#define SIOCDIFADDR_IN6   _IOW('i', 25, struct in6_ifreq)
> +#define SIOCAIFADDR_IN6   _IOW('i', 26, struct in6_aliasreq)
>  
>  #define SIOCGIFDSTADDR_IN6   _IOWR('i', 34, struct in6_ifreq)
>  #define SIOCGIFNETMASK_IN6   _IOWR('i', 37, struct in6_ifreq)
>  
> -#define SIOCDIFADDR_IN6   _IOW('i', 25, struct in6_ifreq)
> -#define SIOCAIFADDR_IN6   _IOW('i', 26, struct in6_aliasreq)
> -
>  #define SIOCGIFAFLAG_IN6 _IOWR('i', 73, struct in6_ifreq)
>  
>  #define SIOCGIFINFO_IN6  _IOWR('i', 108, struct in6_ndireq)
> -#define SIOCSNDFLUSH_IN6 _IOWR('i', 77, struct in6_ifreq)
>  #define SIOCGNBRINFO_IN6 _IOWR('i', 78, struct in6_nbrinfo)
> -#define SIOCSPFXFLUSH_IN6_IOWR('i', 79, struct in6_ifreq)
> -#define SIOCSRTRFLUSH_IN6_IOWR('i', 80, struct in6_ifreq)
>  
>  #define SIOCGIFALIFETIME_IN6 _IOWR('i', 81, struct in6_ifreq)
> -#define SIOCGIFSTAT_IN6  _IOWR('i', 83, struct in6_ifreq)
> -#define 

Re: Kill deprecated IPv6 ioctl(2)s

2017-10-25 Thread Florian Obser
On Wed, Oct 25, 2017 at 10:56:40AM +, Martin Pieuchot wrote:
> On 25/10/17(Wed) 21:53, Jonathan Gray wrote:
> > On Wed, Oct 25, 2017 at 12:20:45PM +0200, Martin Pieuchot wrote:
> > > Diff below remove some more deprecated ioctl(2).  The first group below
> > > correspond to features now deprecated by slaacd(8):
> > > 
> > >   SIOCSIFINFO_FLAGS, SIOCSNDFLUSH_IN6, SIOCSPFXFLUSH_IN6, 
> > > SIOCSRTRFLUSH_IN6
> > > 
> > > Removing those might break some ports.  This is good!  Because now they
> > > are broken at compile time and can be fixed.  Currently they might or
> > > might not work.  On codesearch.debian.net only dhcpcd5 seems to try to use
> > > them.
> > > 
> > > The second group of ioctl(2)s is not used in base and should be used
> > > conditionally in ports, so it should be safe:
> > >   SIOCGIFADDR_IN6, SIOCGIFSTAT_IN6, SIOCGIFSTAT_ICMP6
> > > 
> > > Diff below also move some define around in netinet6/in6_var.h to reduce
> > > the number of #ifdef _KERNEL chunks.
> > > 
> > > ok?
> > 
> > no, this will break the build
> > 
> > src/usr.sbin/ndp/ndp.c: if (ioctl(s, SIOCSNDFLUSH_IN6, 
> > (caddr_t)) < 0)
> 
> This is dead code, here's a diff to remove it, ok?
> 

oops, forgot to remove that when i was in there :(

OK florian@

> Index: ndp.c
> ===
> RCS file: /cvs/src/usr.sbin/ndp/ndp.c,v
> retrieving revision 1.86
> diff -u -p -r1.86 ndp.c
> --- ndp.c 9 Aug 2017 17:35:38 -   1.86
> +++ ndp.c 25 Oct 2017 10:55:22 -
> @@ -135,7 +135,6 @@ void usage(void);
>  int rtmsg(int);
>  int rtget(struct sockaddr_in6 **, struct sockaddr_dl **);
>  void ifinfo(char *);
> -void harmonize_rtr(void);
>  static char *sec2str(time_t);
>  static void ts_print(const struct timeval *);
>  static int rdomain;
> @@ -904,21 +903,6 @@ ifinfo(char *ifname)
>   printf(", reachable=%ds", nd.ndi.reachable);
>   printf(", retrans=%ds%dms\n", nd.ndi.retrans / 1000,
>   nd.ndi.retrans % 1000);
> -
> - close(s);
> -}
> -
> -void
> -harmonize_rtr(void)
> -{
> - char dummyif[IFNAMSIZ+8];
> - int s;
> -
> - if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
> - err(1, "socket");
> - strlcpy(dummyif, "lo0", sizeof(dummyif)); /* dummy */
> - if (ioctl(s, SIOCSNDFLUSH_IN6, (caddr_t)) < 0)
> - err(1, "ioctl(SIOCSNDFLUSH_IN6)");
>  
>   close(s);
>  }
> 

-- 
I'm not entirely sure you are real.



Re: Kill deprecated IPv6 ioctl(2)s

2017-10-25 Thread Jonathan Gray
On Wed, Oct 25, 2017 at 12:56:40PM +0200, Martin Pieuchot wrote:
> On 25/10/17(Wed) 21:53, Jonathan Gray wrote:
> > On Wed, Oct 25, 2017 at 12:20:45PM +0200, Martin Pieuchot wrote:
> > > Diff below remove some more deprecated ioctl(2).  The first group below
> > > correspond to features now deprecated by slaacd(8):
> > > 
> > >   SIOCSIFINFO_FLAGS, SIOCSNDFLUSH_IN6, SIOCSPFXFLUSH_IN6, 
> > > SIOCSRTRFLUSH_IN6
> > > 
> > > Removing those might break some ports.  This is good!  Because now they
> > > are broken at compile time and can be fixed.  Currently they might or
> > > might not work.  On codesearch.debian.net only dhcpcd5 seems to try to use
> > > them.
> > > 
> > > The second group of ioctl(2)s is not used in base and should be used
> > > conditionally in ports, so it should be safe:
> > >   SIOCGIFADDR_IN6, SIOCGIFSTAT_IN6, SIOCGIFSTAT_ICMP6
> > > 
> > > Diff below also move some define around in netinet6/in6_var.h to reduce
> > > the number of #ifdef _KERNEL chunks.
> > > 
> > > ok?
> > 
> > no, this will break the build
> > 
> > src/usr.sbin/ndp/ndp.c: if (ioctl(s, SIOCSNDFLUSH_IN6, 
> > (caddr_t)) < 0)
> 
> This is dead code, here's a diff to remove it, ok?

sure, call to that was removed in 1.83

> 
> Index: ndp.c
> ===
> RCS file: /cvs/src/usr.sbin/ndp/ndp.c,v
> retrieving revision 1.86
> diff -u -p -r1.86 ndp.c
> --- ndp.c 9 Aug 2017 17:35:38 -   1.86
> +++ ndp.c 25 Oct 2017 10:55:22 -
> @@ -135,7 +135,6 @@ void usage(void);
>  int rtmsg(int);
>  int rtget(struct sockaddr_in6 **, struct sockaddr_dl **);
>  void ifinfo(char *);
> -void harmonize_rtr(void);
>  static char *sec2str(time_t);
>  static void ts_print(const struct timeval *);
>  static int rdomain;
> @@ -904,21 +903,6 @@ ifinfo(char *ifname)
>   printf(", reachable=%ds", nd.ndi.reachable);
>   printf(", retrans=%ds%dms\n", nd.ndi.retrans / 1000,
>   nd.ndi.retrans % 1000);
> -
> - close(s);
> -}
> -
> -void
> -harmonize_rtr(void)
> -{
> - char dummyif[IFNAMSIZ+8];
> - int s;
> -
> - if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
> - err(1, "socket");
> - strlcpy(dummyif, "lo0", sizeof(dummyif)); /* dummy */
> - if (ioctl(s, SIOCSNDFLUSH_IN6, (caddr_t)) < 0)
> - err(1, "ioctl(SIOCSNDFLUSH_IN6)");
>  
>   close(s);
>  }
> 



Re: Kill deprecated IPv6 ioctl(2)s

2017-10-25 Thread Martin Pieuchot
On 25/10/17(Wed) 21:53, Jonathan Gray wrote:
> On Wed, Oct 25, 2017 at 12:20:45PM +0200, Martin Pieuchot wrote:
> > Diff below remove some more deprecated ioctl(2).  The first group below
> > correspond to features now deprecated by slaacd(8):
> > 
> >   SIOCSIFINFO_FLAGS, SIOCSNDFLUSH_IN6, SIOCSPFXFLUSH_IN6, SIOCSRTRFLUSH_IN6
> > 
> > Removing those might break some ports.  This is good!  Because now they
> > are broken at compile time and can be fixed.  Currently they might or
> > might not work.  On codesearch.debian.net only dhcpcd5 seems to try to use
> > them.
> > 
> > The second group of ioctl(2)s is not used in base and should be used
> > conditionally in ports, so it should be safe:
> >   SIOCGIFADDR_IN6, SIOCGIFSTAT_IN6, SIOCGIFSTAT_ICMP6
> > 
> > Diff below also move some define around in netinet6/in6_var.h to reduce
> > the number of #ifdef _KERNEL chunks.
> > 
> > ok?
> 
> no, this will break the build
> 
> src/usr.sbin/ndp/ndp.c:   if (ioctl(s, SIOCSNDFLUSH_IN6, 
> (caddr_t)) < 0)

This is dead code, here's a diff to remove it, ok?

Index: ndp.c
===
RCS file: /cvs/src/usr.sbin/ndp/ndp.c,v
retrieving revision 1.86
diff -u -p -r1.86 ndp.c
--- ndp.c   9 Aug 2017 17:35:38 -   1.86
+++ ndp.c   25 Oct 2017 10:55:22 -
@@ -135,7 +135,6 @@ void usage(void);
 int rtmsg(int);
 int rtget(struct sockaddr_in6 **, struct sockaddr_dl **);
 void ifinfo(char *);
-void harmonize_rtr(void);
 static char *sec2str(time_t);
 static void ts_print(const struct timeval *);
 static int rdomain;
@@ -904,21 +903,6 @@ ifinfo(char *ifname)
printf(", reachable=%ds", nd.ndi.reachable);
printf(", retrans=%ds%dms\n", nd.ndi.retrans / 1000,
nd.ndi.retrans % 1000);
-
-   close(s);
-}
-
-void
-harmonize_rtr(void)
-{
-   char dummyif[IFNAMSIZ+8];
-   int s;
-
-   if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
-   err(1, "socket");
-   strlcpy(dummyif, "lo0", sizeof(dummyif)); /* dummy */
-   if (ioctl(s, SIOCSNDFLUSH_IN6, (caddr_t)) < 0)
-   err(1, "ioctl(SIOCSNDFLUSH_IN6)");
 
close(s);
 }



Kill deprecated IPv6 ioctl(2)s

2017-10-25 Thread Martin Pieuchot
Diff below remove some more deprecated ioctl(2).  The first group below
correspond to features now deprecated by slaacd(8):

  SIOCSIFINFO_FLAGS, SIOCSNDFLUSH_IN6, SIOCSPFXFLUSH_IN6, SIOCSRTRFLUSH_IN6

Removing those might break some ports.  This is good!  Because now they
are broken at compile time and can be fixed.  Currently they might or
might not work.  On codesearch.debian.net only dhcpcd5 seems to try to use
them.

The second group of ioctl(2)s is not used in base and should be used
conditionally in ports, so it should be safe:
  SIOCGIFADDR_IN6, SIOCGIFSTAT_IN6, SIOCGIFSTAT_ICMP6

Diff below also move some define around in netinet6/in6_var.h to reduce
the number of #ifdef _KERNEL chunks.

ok?

Index: netinet6/in6.c
===
RCS file: /cvs/src/sys/netinet6/in6.c,v
retrieving revision 1.215
diff -u -p -r1.215 in6.c
--- netinet6/in6.c  24 Oct 2017 09:30:15 -  1.215
+++ netinet6/in6.c  25 Oct 2017 10:06:05 -
@@ -213,13 +213,6 @@ in6_ioctl(u_long cmd, caddr_t data, stru
return (EOPNOTSUPP);
 
switch (cmd) {
-   case SIOCSNDFLUSH_IN6:
-   case SIOCSPFXFLUSH_IN6:
-   case SIOCSRTRFLUSH_IN6:
-   case SIOCSIFINFO_FLAGS:
-   if (!privileged)
-   return (EPERM);
-   /* FALLTHROUGH */
case SIOCGIFINFO_IN6:
case SIOCGNBRINFO_IN6:
return (nd6_ioctl(cmd, data, ifp));
@@ -241,17 +234,11 @@ in6_ioctl(u_long cmd, caddr_t data, stru
case SIOCAIFADDR_IN6:
sa6 = >ifra_addr;
break;
-   case SIOCGIFADDR_IN6:
case SIOCGIFDSTADDR_IN6:
case SIOCGIFNETMASK_IN6:
case SIOCDIFADDR_IN6:
case SIOCGIFAFLAG_IN6:
-   case SIOCSNDFLUSH_IN6:
-   case SIOCSPFXFLUSH_IN6:
-   case SIOCSRTRFLUSH_IN6:
case SIOCGIFALIFETIME_IN6:
-   case SIOCGIFSTAT_IN6:
-   case SIOCGIFSTAT_ICMP6:
sa6 = >ifr_addr;
break;
case SIOCSIFADDR:
@@ -313,9 +300,6 @@ in6_ioctl(u_long cmd, caddr_t data, stru
 
break;
 
-   case SIOCGIFADDR_IN6:
-   /* This interface is basically deprecated. use SIOCGIFCONF. */
-   /* FALLTHROUGH */
case SIOCGIFAFLAG_IN6:
case SIOCGIFNETMASK_IN6:
case SIOCGIFDSTADDR_IN6:
@@ -328,10 +312,6 @@ in6_ioctl(u_long cmd, caddr_t data, stru
 
switch (cmd) {
 
-   case SIOCGIFADDR_IN6:
-   ifr->ifr_addr = ia6->ia_addr;
-   break;
-
case SIOCGIFDSTADDR_IN6:
if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
return (EINVAL);
@@ -349,10 +329,6 @@ in6_ioctl(u_long cmd, caddr_t data, stru
case SIOCGIFAFLAG_IN6:
ifr->ifr_ifru.ifru_flags6 = ia6->ia6_flags;
break;
-
-   case SIOCGIFSTAT_IN6:
-   case SIOCGIFSTAT_ICMP6:
-   return (EOPNOTSUPP);
 
case SIOCGIFALIFETIME_IN6:
ifr->ifr_ifru.ifru_lifetime = ia6->ia6_lifetime;
Index: netinet6/in6_var.h
===
RCS file: /cvs/src/sys/netinet6/in6_var.h,v
retrieving revision 1.70
diff -u -p -r1.70 in6_var.h
--- netinet6/in6_var.h  24 Oct 2017 09:36:13 -  1.70
+++ netinet6/in6_var.h  25 Oct 2017 10:06:05 -
@@ -278,40 +278,21 @@ structin6_aliasreq {
 #define IFA_IN6(x) (&((struct sockaddr_in6 *)((x)->ifa_addr))->sin6_addr)
 #define IFA_DSTIN6(x)  (&((struct sockaddr_in6 
*)((x)->ifa_dstaddr))->sin6_addr)
 
-#ifdef _KERNEL
-#define IN6_ARE_MASKED_ADDR_EQUAL(d, a, m) (   \
-   (((d)->s6_addr32[0] ^ (a)->s6_addr32[0]) & (m)->s6_addr32[0]) == 0 && \
-   (((d)->s6_addr32[1] ^ (a)->s6_addr32[1]) & (m)->s6_addr32[1]) == 0 && \
-   (((d)->s6_addr32[2] ^ (a)->s6_addr32[2]) & (m)->s6_addr32[2]) == 0 && \
-   (((d)->s6_addr32[3] ^ (a)->s6_addr32[3]) & (m)->s6_addr32[3]) == 0 )
-#endif /* _KERNEL */
-
-#define SIOCGIFADDR_IN6_IOWR('i', 33, struct in6_ifreq)
+#define SIOCDIFADDR_IN6 _IOW('i', 25, struct in6_ifreq)
+#define SIOCAIFADDR_IN6 _IOW('i', 26, struct in6_aliasreq)
 
 #define SIOCGIFDSTADDR_IN6 _IOWR('i', 34, struct in6_ifreq)
 #define SIOCGIFNETMASK_IN6 _IOWR('i', 37, struct in6_ifreq)
 
-#define SIOCDIFADDR_IN6 _IOW('i', 25, struct in6_ifreq)
-#define SIOCAIFADDR_IN6 _IOW('i', 26, struct in6_aliasreq)
-
 #define SIOCGIFAFLAG_IN6   _IOWR('i', 73, struct in6_ifreq)
 
 #define SIOCGIFINFO_IN6_IOWR('i', 108, struct in6_ndireq)
-#define SIOCSNDFLUSH_IN6   _IOWR('i', 77, struct in6_ifreq)
 #define SIOCGNBRINFO_IN6   _IOWR('i', 78, struct in6_nbrinfo)
-#define SIOCSPFXFLUSH_IN6  _IOWR('i', 79, struct in6_ifreq)
-#define SIOCSRTRFLUSH_IN6  _IOWR('i', 80, struct in6_ifreq)
 
 #define SIOCGIFALIFETIME_IN6   _IOWR('i', 81, struct in6_ifreq)