svn commit: r228768 - in head/sys: net netinet netinet6 sys
Gleb Smirnoff
glebius at FreeBSD.org
Wed Dec 21 12:39:09 UTC 2011
Author: glebius
Date: Wed Dec 21 12:39:08 2011
New Revision: 228768
URL: http://svn.freebsd.org/changeset/base/228768
Log:
Provide ABI compatibility shim to enable configuring of addresses
with ifconfig(8) prior to r228571.
Requested by: brooks
Modified:
head/sys/net/if.h
head/sys/netinet/in.c
head/sys/netinet6/in6.c
head/sys/netinet6/in6_var.h
head/sys/sys/sockio.h
Modified: head/sys/net/if.h
==============================================================================
--- head/sys/net/if.h Wed Dec 21 12:21:22 2011 (r228767)
+++ head/sys/net/if.h Wed Dec 21 12:39:08 2011 (r228768)
@@ -362,6 +362,14 @@ struct ifaliasreq {
int ifra_vhid;
};
+/* Compat with pre-10.x */
+struct oifaliasreq {
+ char ifra_name[IFNAMSIZ];
+ struct sockaddr ifra_addr;
+ struct sockaddr ifra_broadaddr;
+ struct sockaddr ifra_mask;
+};
+
struct ifmediareq {
char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */
int ifm_current; /* current media options */
Modified: head/sys/netinet/in.c
==============================================================================
--- head/sys/netinet/in.c Wed Dec 21 12:21:22 2011 (r228767)
+++ head/sys/netinet/in.c Wed Dec 21 12:39:08 2011 (r228768)
@@ -223,6 +223,14 @@ in_control(struct socket *so, u_long cmd
struct sockaddr_in oldaddr;
int error, hostIsNew, iaIsNew, maskIsNew;
int iaIsFirst;
+ u_long ocmd = cmd;
+
+ /*
+ * Pre-10.x compat: OSIOCAIFADDR passes a shorter
+ * struct in_aliasreq, without ifra_vhid.
+ */
+ if (cmd == OSIOCAIFADDR)
+ cmd = SIOCAIFADDR;
ia = NULL;
iaIsFirst = 0;
@@ -253,10 +261,18 @@ in_control(struct socket *so, u_long cmd
sizeof(struct sockaddr_in) ||
ifra->ifra_broadaddr.sin_family != AF_INET))
return (EINVAL);
+#if 0
+ /*
+ * ifconfig(8) in pre-10.x doesn't set sin_family for the
+ * mask. The code is disabled for the 10.x timeline, to
+ * make SIOCAIFADDR compatible with 9.x ifconfig(8).
+ * The code should be enabled in 11.x
+ */
if (ifra->ifra_mask.sin_len != 0 &&
(ifra->ifra_mask.sin_len != sizeof(struct sockaddr_in) ||
ifra->ifra_mask.sin_family != AF_INET))
return (EINVAL);
+#endif
break;
case SIOCSIFADDR:
case SIOCSIFBRDADDR:
@@ -564,7 +580,7 @@ in_control(struct socket *so, u_long cmd
}
if (hostIsNew || maskIsNew)
error = in_ifinit(ifp, ia, &ifra->ifra_addr, 0,
- maskIsNew, ifra->ifra_vhid);
+ maskIsNew, (ocmd == cmd ? ifra->ifra_vhid : 0));
if (error != 0 && iaIsNew)
break;
Modified: head/sys/netinet6/in6.c
==============================================================================
--- head/sys/netinet6/in6.c Wed Dec 21 12:21:22 2011 (r228767)
+++ head/sys/netinet6/in6.c Wed Dec 21 12:39:08 2011 (r228768)
@@ -275,6 +275,13 @@ in6_control(struct socket *so, u_long cm
struct sockaddr_in6 *sa6;
int carp_attached = 0;
int error;
+ u_long ocmd = cmd;
+
+ /*
+ * Compat to make pre-10.x ifconfig(8) operable.
+ */
+ if (cmd == OSIOCAIFADDR_IN6)
+ cmd = SIOCAIFADDR_IN6;
switch (cmd) {
case SIOCGETSGCNT_IN6:
@@ -654,7 +661,7 @@ in6_control(struct socket *so, u_long cm
break;
}
- if (ifra->ifra_vhid > 0) {
+ if (cmd == ocmd && ifra->ifra_vhid > 0) {
if (carp_attach_p != NULL)
error = (*carp_attach_p)(&ia->ia_ifa,
ifra->ifra_vhid);
Modified: head/sys/netinet6/in6_var.h
==============================================================================
--- head/sys/netinet6/in6_var.h Wed Dec 21 12:21:22 2011 (r228767)
+++ head/sys/netinet6/in6_var.h Wed Dec 21 12:39:08 2011 (r228768)
@@ -290,6 +290,16 @@ struct in6_aliasreq {
int ifra_vhid;
};
+/* pre-10.x compat */
+struct oin6_aliasreq {
+ char ifra_name[IFNAMSIZ];
+ struct sockaddr_in6 ifra_addr;
+ struct sockaddr_in6 ifra_dstaddr;
+ struct sockaddr_in6 ifra_prefixmask;
+ int ifra_flags;
+ struct in6_addrlifetime ifra_lifetime;
+};
+
/* prefix type macro */
#define IN6_PREFIX_ND 1
#define IN6_PREFIX_RR 2
@@ -410,7 +420,8 @@ struct in6_rrenumreq {
#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 OSIOCAIFADDR_IN6 _IOW('i', 26, struct oin6_aliasreq)
+#define SIOCAIFADDR_IN6 _IOW('i', 27, struct in6_aliasreq)
#define SIOCSIFPHYADDR_IN6 _IOW('i', 70, struct in6_aliasreq)
#define SIOCGIFPSRCADDR_IN6 _IOWR('i', 71, struct in6_ifreq)
Modified: head/sys/sys/sockio.h
==============================================================================
--- head/sys/sys/sockio.h Wed Dec 21 12:21:22 2011 (r228767)
+++ head/sys/sys/sockio.h Wed Dec 21 12:39:08 2011 (r228768)
@@ -68,8 +68,7 @@
#define SIOCGIFMETRIC _IOWR('i', 23, struct ifreq) /* get IF metric */
#define SIOCSIFMETRIC _IOW('i', 24, struct ifreq) /* set IF metric */
#define SIOCDIFADDR _IOW('i', 25, struct ifreq) /* delete IF addr */
-#define SIOCAIFADDR _IOW('i', 26, struct ifaliasreq)/* add/chg IF alias */
-
+#define OSIOCAIFADDR _IOW('i', 26, struct oifaliasreq)/* add/chg IF alias */
#define SIOCALIFADDR _IOW('i', 27, struct if_laddrreq) /* add IF addr */
#define SIOCGLIFADDR _IOWR('i', 28, struct if_laddrreq) /* get IF addr */
#define SIOCDLIFADDR _IOW('i', 29, struct if_laddrreq) /* delete IF addr */
@@ -81,6 +80,7 @@
#define SIOCSIFNAME _IOW('i', 40, struct ifreq) /* set IF name */
#define SIOCSIFDESCR _IOW('i', 41, struct ifreq) /* set ifnet descr */
#define SIOCGIFDESCR _IOWR('i', 42, struct ifreq) /* get ifnet descr */
+#define SIOCAIFADDR _IOW('i', 43, struct ifaliasreq)/* add/chg IF alias */
#define SIOCADDMULTI _IOW('i', 49, struct ifreq) /* add m'cast addr */
#define SIOCDELMULTI _IOW('i', 50, struct ifreq) /* del m'cast addr */
More information about the svn-src-head
mailing list