Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Jan 2012 18:36:16 +0400
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        net@FreeBSD.org
Subject:   removing support for SIOCSIF{ADDR,NETMASK,BRDADDR,DSTADDR}
Message-ID:  <20120112143616.GK74141@glebius.int.ru>

next in thread | raw e-mail | index | archive | help

--Kj7319i9nmIyA2yE
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline

  Hello, networkers!

  I'd like to remove from kernel support for several really outdated
ioctls:

  SIOCSIFADDR
  SIOCSIFNETMASK
  SIOCSIFBRDADDR
  SIOCSIFDSTADDR

Actually their support was always only declared, you can trigger panics
easily if you play with them.

These ioctls were outdated even in FreeBSD 1.0, since ifconfig(8) always
used SIOCAIFADDR. There is no reason to have them in modern system.

The ports team had performed an -exp run to determine number of ports
that still use them:

http://www.freebsd.org/cgi/query-pr.cgi?pr=163524&cat=

We appeared to have three ports, that a kernel interface drivers, and
they utilize SIOCSIFADDR. However, they utilize it in the in-kernel
API, and this usage is not related to the ioctl() call from userland.

We don't have any ports in the tree, that use the above commands as
ioctl() argument.

So, any objections on removal?

-- 
Totus tuus, Glebius.

--Kj7319i9nmIyA2yE
Content-Type: text/x-diff; charset=koi8-r
Content-Disposition: attachment; filename="in.c.diff"

Index: in.c
===================================================================
--- in.c	(revision 229775)
+++ in.c	(working copy)
@@ -73,7 +73,7 @@
 
 static void	in_socktrim(struct sockaddr_in *);
 static int	in_ifinit(struct ifnet *, struct in_ifaddr *,
-		    struct sockaddr_in *, int, int, int);
+		    struct sockaddr_in *, int, int);
 static void	in_purgemaddrs(struct ifnet *);
 
 static VNET_DEFINE(int, nosameprefix);
@@ -220,7 +220,6 @@
 	struct in_addr dst;
 	struct in_ifinfo *ii;
 	struct in_aliasreq *ifra = (struct in_aliasreq *)data;
-	struct sockaddr_in oldaddr;
 	int error, hostIsNew, iaIsNew, maskIsNew;
 	int iaIsFirst;
 	u_long ocmd = cmd;
@@ -278,10 +277,8 @@
 	case SIOCSIFBRDADDR:
 	case SIOCSIFDSTADDR:
 	case SIOCSIFNETMASK:
-		if (ifr->ifr_addr.sa_family != AF_INET ||
-		    ifr->ifr_addr.sa_len != sizeof(struct sockaddr_in))
-			return (EINVAL);
-		break;
+		/* We no longer support that old commands. */
+		return (EINVAL);
 
 	case SIOCALIFADDR:
 		if (td != NULL) {
@@ -322,10 +319,6 @@
 	 */
 	switch (cmd) {
 	case SIOCAIFADDR:
-	case SIOCSIFADDR:
-	case SIOCSIFBRDADDR:
-	case SIOCSIFNETMASK:
-	case SIOCSIFDSTADDR:
 		if (td != NULL) {
 			error = priv_check(td, PRIV_NET_ADDIFADDR);
 			if (error)
@@ -413,10 +406,6 @@
 			error = EADDRNOTAVAIL;
 			goto out;
 		}
-		/* FALLTHROUGH */
-	case SIOCSIFADDR:
-	case SIOCSIFNETMASK:
-	case SIOCSIFDSTADDR:
 		if (ia == NULL) {
 			ia = (struct in_ifaddr *)
 				malloc(sizeof *ia, M_IFADDR, M_NOWAIT |
@@ -452,7 +441,6 @@
 		}
 		break;
 
-	case SIOCSIFBRDADDR:
 	case SIOCGIFADDR:
 	case SIOCGIFNETMASK:
 	case SIOCGIFDSTADDR:
@@ -493,61 +481,6 @@
 		*((struct sockaddr_in *)&ifr->ifr_addr) = ia->ia_sockmask;
 		goto out;
 
-	case SIOCSIFDSTADDR:
-		if ((ifp->if_flags & IFF_POINTOPOINT) == 0) {
-			error = EINVAL;
-			goto out;
-		}
-		oldaddr = ia->ia_dstaddr;
-		ia->ia_dstaddr = *(struct sockaddr_in *)&ifr->ifr_dstaddr;
-		if (ifp->if_ioctl != NULL) {
-			error = (*ifp->if_ioctl)(ifp, SIOCSIFDSTADDR,
-			    (caddr_t)ia);
-			if (error) {
-				ia->ia_dstaddr = oldaddr;
-				goto out;
-			}
-		}
-		if (ia->ia_flags & IFA_ROUTE) {
-			ia->ia_ifa.ifa_dstaddr = (struct sockaddr *)&oldaddr;
-			rtinit(&(ia->ia_ifa), (int)RTM_DELETE, RTF_HOST);
-			ia->ia_ifa.ifa_dstaddr =
-					(struct sockaddr *)&ia->ia_dstaddr;
-			rtinit(&(ia->ia_ifa), (int)RTM_ADD, RTF_HOST|RTF_UP);
-		}
-		goto out;
-
-	case SIOCSIFBRDADDR:
-		if ((ifp->if_flags & IFF_BROADCAST) == 0) {
-			error = EINVAL;
-			goto out;
-		}
-		ia->ia_broadaddr = *(struct sockaddr_in *)&ifr->ifr_broadaddr;
-		goto out;
-
-	case SIOCSIFADDR:
-		error = in_ifinit(ifp, ia,
-		    (struct sockaddr_in *) &ifr->ifr_addr, 1, 0, 0);
-		if (error != 0 && iaIsNew)
-			break;
-		if (error == 0) {
-			ii = ((struct in_ifinfo *)ifp->if_afdata[AF_INET]);
-			if (iaIsFirst &&
-			    (ifp->if_flags & IFF_MULTICAST) != 0) {
-				error = in_joingroup(ifp, &allhosts_addr,
-				    NULL, &ii->ii_allhosts);
-			}
-			EVENTHANDLER_INVOKE(ifaddr_event, ifp);
-		}
-		error = 0;
-		goto out;
-
-	case SIOCSIFNETMASK:
-		ia->ia_sockmask.sin_addr = ((struct sockaddr_in *)
-		    &ifr->ifr_addr)->sin_addr;
-		ia->ia_subnetmask = ntohl(ia->ia_sockmask.sin_addr.s_addr);
-		goto out;
-
 	case SIOCAIFADDR:
 		maskIsNew = 0;
 		hostIsNew = 1;
@@ -579,8 +512,8 @@
 			maskIsNew  = 1; /* We lie; but the effect's the same */
 		}
 		if (hostIsNew || maskIsNew)
-			error = in_ifinit(ifp, ia, &ifra->ifra_addr, 0,
-			    maskIsNew, (ocmd == cmd ? ifra->ifra_vhid : 0));
+			error = in_ifinit(ifp, ia, &ifra->ifra_addr, maskIsNew,
+			    (ocmd == cmd ? ifra->ifra_vhid : 0));
 		if (error != 0 && iaIsNew)
 			break;
 
@@ -863,14 +796,11 @@
  */
 static int
 in_ifinit(struct ifnet *ifp, struct in_ifaddr *ia, struct sockaddr_in *sin,
-    int scrub, int masksupplied, int vhid)
+    int masksupplied, int vhid)
 {
 	register u_long i = ntohl(sin->sin_addr.s_addr);
 	int flags = RTF_UP, error = 0;
 
-	if (scrub)
-		in_scrubprefix(ia, LLE_STATIC);
-
 	IN_IFADDR_WLOCK();
 	if (ia->ia_addr.sin_family == AF_INET)
 		LIST_REMOVE(ia, ia_hash);

--Kj7319i9nmIyA2yE--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120112143616.GK74141>