Update `ifconfig` tool for ipv6.

This commit is contained in:
root 2019-07-15 16:18:02 +08:00
parent e499fe2b2a
commit c8c8cfb777
3 changed files with 30 additions and 3 deletions

View File

@ -36,9 +36,12 @@ ifconfig -p <f-stack proc_id> [-f type:format] %sinterface address_family
ifconfig -p <f-stack proc_id> -l [-d] [-u] [address_family]
ifconfig -p <f-stack proc_id> %s[-d] [-m] [-u] [-v]
```
We has supportted inet6, you can config ipv6 address like this:
ifconfig -p <f-stack proc_id> interface inet6 <ipv6 address> autoconf
Unsupported interfaces or parameters:
```
inet6
MAC(Mandatory Access Control)
media
SFP/SFP+
@ -77,6 +80,7 @@ Examples:
Display the route for a destination network:
./sbin/route -p 0 show 172.16.10.0
./sbin/route -p 0 -6 show ::/0
Delete a static route from the routing table:

View File

@ -53,7 +53,7 @@ ioctl_va(int fd, unsigned long com, void *data, int argc, ...)
unsigned size;
void *cpy_mem;
size_t offset, clen;
int af = 0;
int af = AF_INET;
if (argc != 0 && argc != 3 && argc != 1) {
errno = EINVAL;
@ -107,6 +107,7 @@ ioctl_va(int fd, unsigned long com, void *data, int argc, ...)
msg->msg_type = FF_IOCTL;
else {
errno = EINVAL;
ff_ipc_msg_free(msg);
return -1;
}

View File

@ -76,7 +76,11 @@ setnd6flags(const char *dummyaddr __unused,
memset(&nd, 0, sizeof(nd));
strlcpy(nd.ifname, ifr.ifr_name, sizeof(nd.ifname));
error = ioctl(s, SIOCGIFINFO_IN6, &nd);
#ifndef FSTACK
error = ioctl(s, SIOCGIFINFO_IN6, (caddr_t)&nd);
#else
error = ioctl_va(s, SIOCGIFINFO_IN6, (caddr_t)&nd, 1, AF_INET6);
#endif
if (error) {
warn("ioctl(SIOCGIFINFO_IN6)");
return;
@ -85,7 +89,12 @@ setnd6flags(const char *dummyaddr __unused,
nd.ndi.flags &= ~(-d);
else
nd.ndi.flags |= d;
#ifndef FSTACK
error = ioctl(s, SIOCSIFINFO_IN6, (caddr_t)&nd);
#else
error = ioctl_va(s, SIOCSIFINFO_IN6, (caddr_t)&nd, 1, AF_INET6);
#endif
if (error)
warn("ioctl(SIOCSIFINFO_IN6)");
}
@ -114,7 +123,11 @@ setnd6defif(const char *dummyaddr __unused,
}
ndifreq.ifindex = ifindex;
#ifndef FSTACK
error = ioctl(s, SIOCSDEFIFACE_IN6, (caddr_t)&ndifreq);
#else
error = ioctl_va(s, SIOCSDEFIFACE_IN6, (caddr_t)&ndifreq, 1, AF_INET6);
#endif
if (error)
warn("ioctl(SIOCSDEFIFACE_IN6)");
}
@ -130,7 +143,11 @@ isnd6defif(int s)
strlcpy(ndifreq.ifname, ifr.ifr_name, sizeof(ndifreq.ifname));
ifindex = if_nametoindex(ndifreq.ifname);
#ifndef FSTACK
error = ioctl(s, SIOCGDEFIFACE_IN6, (caddr_t)&ndifreq);
#else
error = ioctl_va(s, SIOCGDEFIFACE_IN6, (caddr_t)&ndifreq, 1, AF_INET6);
#endif
if (error) {
warn("ioctl(SIOCGDEFIFACE_IN6)");
return (error);
@ -153,7 +170,12 @@ nd6_status(int s)
warn("socket(AF_INET6, SOCK_DGRAM)");
return;
}
#ifndef FSTACK
error = ioctl(s6, SIOCGIFINFO_IN6, &nd);
#else
error = ioctl_va(s, SIOCGIFINFO_IN6, (caddr_t)&nd, 1, AF_INET6);
#endif
if (error) {
if (errno != EPFNOSUPPORT)
warn("ioctl(SIOCGIFINFO_IN6)");