summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/in.c11
-rw-r--r--sys/sys/sockio.h1
2 files changed, 11 insertions, 1 deletions
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index be26ecd..9c44b87 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -315,6 +315,7 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp,
* Security checks before we get involved in any work.
*/
switch (cmd) {
+ case SIOCORDERIFADDR:
case SIOCAIFADDR:
if (td != NULL) {
error = priv_check(td, PRIV_NET_ADDIFADDR);
@@ -374,6 +375,7 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp,
error = 0;
switch (cmd) {
+ case SIOCORDERIFADDR:
case SIOCAIFADDR:
case SIOCDIFADDR:
if (ifra->ifra_addr.sin_family == AF_INET) {
@@ -399,10 +401,17 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp,
goto out;
}
}
- if (cmd == SIOCDIFADDR && ia == NULL) {
+ if ((cmd == SIOCDIFADDR || cmd == SIOCORDERIFADDR) && ia == NULL) {
error = EADDRNOTAVAIL;
goto out;
}
+ if (cmd == SIOCORDERIFADDR && ia != NULL) {
+ IF_ADDR_WLOCK(ifp);
+ TAILQ_REMOVE(&ifp->if_addrhead, &ia->ia_ifa, ifa_link);
+ TAILQ_INSERT_AFTER(&ifp->if_addrhead, TAILQ_FIRST(&ifp->if_addrhead), &ia->ia_ifa, ifa_link);
+ IF_ADDR_WUNLOCK(ifp);
+ goto out;
+ }
if (ia == NULL) {
ia = (struct in_ifaddr *)
malloc(sizeof *ia, M_IFADDR, M_NOWAIT |
diff --git a/sys/sys/sockio.h b/sys/sys/sockio.h
index 2d38e48..5397f77 100644
--- a/sys/sys/sockio.h
+++ b/sys/sys/sockio.h
@@ -127,5 +127,6 @@
#define SIOCGIFGROUP _IOWR('i', 136, struct ifgroupreq) /* get ifgroups */
#define SIOCDIFGROUP _IOW('i', 137, struct ifgroupreq) /* delete ifgroup */
#define SIOCGIFGMEMB _IOWR('i', 138, struct ifgroupreq) /* get members */
+#define SIOCORDERIFADDR _IOWR('i', 139, struct ifaliasreq) /* reorder interface */
#endif /* !_SYS_SOCKIO_H_ */
OpenPOWER on IntegriCloud