Thread (18 messages) 18 messages, 4 authors, 2021-01-28

Re: [PATCH] netdevice.7: Update documentation for SIOCGIFADDR SIOCSIFADDR SIOCDIFADDR

From: Alejandro Colomar (man-pages) <hidden>
Date: 2021-01-02 18:04:59

Hi Pali,

Please, see some comments below.

On 1/2/21 3:02 PM, Pali Rohár wrote:
quoted hunk ↗ jump to hunk
Also add description for struct in6_ifreq which is used for IPv6 addresses.

SIOCSIFADDR and SIOCDIFADDR can be used to add or delete IPv6 address and
pppd is using these ioctls for a long time. Surprisingly SIOCDIFADDR cannot
be used for deleting IPv4 address but only for IPv6 addresses.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 man7/netdevice.7 | 36 +++++++++++++++++++++++++++++-------
 1 file changed, 29 insertions(+), 7 deletions(-)
diff --git a/man7/netdevice.7 b/man7/netdevice.7
index 488e83d9a..5b68e4988 100644
--- a/man7/netdevice.7
+++ b/man7/netdevice.7
@@ -55,9 +55,27 @@ struct ifreq {
 .EE
 .in
 .PP
+Exception is
+.B AF_INET6
+socket for which is used
+.I in6_ifreq
+structure:
Wording fix:

[
AF_INET6 is an exception.
It passes an
.I in6_ifreq
structure:
]

Are there more exceptions?
Or is it the only one?
+.PP
+.in +4n
+.EX
+struct in6_ifreq {
+    struct in6_addr     ifr6_addr;
+    u32                 ifr6_prefixlen;
+    int                 ifr6_ifindex; /* Interface index */
+};
+.EE
+.in
+.PP
 Normally, the user specifies which device to affect by setting
 .I ifr_name
-to the name of the interface.
+to the name of the interface or
+.I ifr6_ifindex
+to the index of the interface.
I've seen there's ifr_ifindex too (see SIOCGIFNAME).
Can it be used in the same way as ifr6_ifindex?
quoted hunk ↗ jump to hunk
 All other members of the structure may
 share memory.
 .SS Ioctls
@@ -142,13 +160,17 @@ IFF_ISATAP:Interface is RFC4214 ISATAP interface.
 .PP
 Setting the extended (private) interface flags is a privileged operation.
 .TP
-.BR SIOCGIFADDR ", " SIOCSIFADDR
-Get or set the address of the device using
-.IR ifr_addr .
-Setting the interface address is a privileged operation.
-For compatibility, only
+.BR SIOCGIFADDR ", " SIOCSIFADDR ", " SIOCDIFADDR
+Get, set or delete the address of the device using
+.IR ifr_addr " or " ifr6_addr " with " ifr6_prefixlen .
Generally, we place each name on a single line.
The line after .TP is an exception, as you can see above.
So this would be:

[
.IR ifr_addr ,
or
.I ifr6_addr
with
.IR ifr6_prefixlen .
]
+Setting or deleting the interface address is a privileged operation.
+For compatibility,
+.BR SIOCGIFADDR " returns only " AF_INET " addresses, "
+.BR SIOCSIFADDR " accepts " AF_INET " and " AF_INET6 " addresses and "
+.BR SIOCDIFADDR " deletes only " AF_INET6 " addresses. "
See above.
 .B AF_INET
-addresses are accepted or returned.
+address can be deleted by setting zero address via
+.BR SIOCSIFADDR .
 .TP
 .BR SIOCGIFDSTADDR ", " SIOCSIFDSTADDR
 Get or set the destination address of a point-to-point device using
Thanks,

Alex

-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help