Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108622616
D26636.id78024.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D26636.id78024.diff
View Options
Index: share/man/man4/netintro.4
===================================================================
--- share/man/man4/netintro.4
+++ share/man/man4/netintro.4
@@ -28,7 +28,7 @@
.\" @(#)netintro.4 8.2 (Berkeley) 11/30/93
.\" $FreeBSD$
.\"
-.Dd January 26, 2012
+.Dd October 2, 2020
.Dt NETINTRO 4
.Os
.Sh NAME
@@ -349,6 +349,13 @@
convention that specification of the default address means
to delete the first address for the interface belonging to
the address family in which the original socket was opened.
+.It Dv SIOCGIFALIAS
+This request provides means to get additional addresses
+together with netmask and broadcast/destination from an
+interface.
+It also uses the
+.Vt ifaliasreq
+structure.
.It Dv SIOCGIFCONF
Get interface configuration list.
This request takes an
Index: sys/netinet/in.c
===================================================================
--- sys/netinet/in.c
+++ sys/netinet/in.c
@@ -72,6 +72,7 @@
static int in_aifaddr_ioctl(u_long, caddr_t, struct ifnet *, struct thread *);
static int in_difaddr_ioctl(u_long, caddr_t, struct ifnet *, struct thread *);
+static int in_gifaddr_ioctl(u_long, caddr_t, struct ifnet *, struct thread *);
static void in_socktrim(struct sockaddr_in *);
static void in_purgemaddrs(struct ifnet *);
@@ -237,6 +238,11 @@
case SIOCGIFDSTADDR:
case SIOCGIFNETMASK:
break;
+ case SIOCGIFALIAS:
+ sx_xlock(&in_control_sx);
+ error = in_gifaddr_ioctl(cmd, data, ifp, td);
+ sx_xunlock(&in_control_sx);
+ return (error);
case SIOCDIFADDR:
sx_xlock(&in_control_sx);
error = in_difaddr_ioctl(cmd, data, ifp, td);
@@ -646,6 +652,60 @@
ifa_free(&ia->ia_ifa); /* in_ifaddrhead */
return (0);
+}
+
+static int
+in_gifaddr_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp, struct thread *td)
+{
+ struct in_aliasreq *ifra = (struct in_aliasreq *)data;
+ const struct sockaddr_in *addr = &ifra->ifra_addr;
+ struct epoch_tracker et;
+ struct ifaddr *ifa;
+ struct in_ifaddr *ia;
+
+ /*
+ * ifra_addr must be present and be of INET family.
+ */
+ if (addr->sin_len != sizeof(struct sockaddr_in) ||
+ addr->sin_family != AF_INET)
+ return (EINVAL);
+
+ /*
+ * See whether address exist.
+ */
+ ia = NULL;
+ NET_EPOCH_ENTER(et);
+ CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
+ struct in_ifaddr *it;
+
+ if (ifa->ifa_addr->sa_family != AF_INET)
+ continue;
+
+ it = (struct in_ifaddr *)ifa;
+ if (it->ia_addr.sin_addr.s_addr == addr->sin_addr.s_addr &&
+ prison_check_ip4(td->td_ucred, &addr->sin_addr) == 0) {
+ ia = it;
+ break;
+ }
+ }
+ if (ia == NULL) {
+ NET_EPOCH_EXIT(et);
+ return (EADDRNOTAVAIL);
+ }
+
+ ifra->ifra_mask = ia->ia_sockmask;
+ if ((ifp->if_flags & IFF_POINTOPOINT) &&
+ ia->ia_dstaddr.sin_family == AF_INET)
+ ifra->ifra_dstaddr = ia->ia_dstaddr;
+ else if ((ifp->if_flags & IFF_BROADCAST) &&
+ ia->ia_broadaddr.sin_family == AF_INET)
+ ifra->ifra_broadaddr = ia->ia_broadaddr;
+ else
+ memset(&ifra->ifra_broadaddr, 0,
+ sizeof(ifra->ifra_broadaddr));
+
+ NET_EPOCH_EXIT(et);
+ return 0;
}
#define rtinitflags(x) \
Index: sys/sys/sockio.h
===================================================================
--- sys/sys/sockio.h
+++ sys/sys/sockio.h
@@ -84,6 +84,7 @@
#define SIOCGIFDESCR _IOWR('i', 42, struct ifreq) /* get ifnet descr */
#define SIOCAIFADDR _IOW('i', 43, struct ifaliasreq)/* add/chg IF alias */
#define SIOCGIFDATA _IOW('i', 44, struct ifreq) /* get if_data */
+#define SIOCGIFALIAS _IOWR('i', 45, struct ifaliasreq)/* get IF alias */
#define SIOCADDMULTI _IOW('i', 49, struct ifreq) /* add m'cast addr */
#define SIOCDELMULTI _IOW('i', 50, struct ifreq) /* del m'cast addr */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 27, 11:01 PM (9 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16219293
Default Alt Text
D26636.id78024.diff (3 KB)
Attached To
Mode
D26636: Implement SIOCGIFALIAS
Attached
Detach File
Event Timeline
Log In to Comment