aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTonghao Zhang <xiangxia.m.yue@gmail.com>2018-01-28 06:38:58 -0500
committerDavid S. Miller <davem@davemloft.net>2018-01-29 14:32:31 -0500
commit30e948a37839c633d18f6c4cf8a212912ba9449c (patch)
treeeef7c45ed1adf85d124930e4447b15f361185a37
parent40ca54e3a686f13117f3de0c443f8026dadf7c44 (diff)
ipv4: Get the address of interface correctly.
When using ioctl to get address of interface, we can't get it anymore. For example, the command is show as below. # ifconfig eth0 In the patch ("03aef17bb79b3"), the devinet_ioctl does not return a suitable value, even though we can find it in the kernel. Then fix it now. Fixes: 03aef17bb79b3 ("devinet_ioctl(): take copyin/copyout to caller") Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com> Acked-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv4/devinet.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index e056c0067f2c..40f001782c1b 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1048,18 +1048,22 @@ int devinet_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr)
1048 1048
1049 switch (cmd) { 1049 switch (cmd) {
1050 case SIOCGIFADDR: /* Get interface address */ 1050 case SIOCGIFADDR: /* Get interface address */
1051 ret = 0;
1051 sin->sin_addr.s_addr = ifa->ifa_local; 1052 sin->sin_addr.s_addr = ifa->ifa_local;
1052 break; 1053 break;
1053 1054
1054 case SIOCGIFBRDADDR: /* Get the broadcast address */ 1055 case SIOCGIFBRDADDR: /* Get the broadcast address */
1056 ret = 0;
1055 sin->sin_addr.s_addr = ifa->ifa_broadcast; 1057 sin->sin_addr.s_addr = ifa->ifa_broadcast;
1056 break; 1058 break;
1057 1059
1058 case SIOCGIFDSTADDR: /* Get the destination address */ 1060 case SIOCGIFDSTADDR: /* Get the destination address */
1061 ret = 0;
1059 sin->sin_addr.s_addr = ifa->ifa_address; 1062 sin->sin_addr.s_addr = ifa->ifa_address;
1060 break; 1063 break;
1061 1064
1062 case SIOCGIFNETMASK: /* Get the netmask for the interface */ 1065 case SIOCGIFNETMASK: /* Get the netmask for the interface */
1066 ret = 0;
1063 sin->sin_addr.s_addr = ifa->ifa_mask; 1067 sin->sin_addr.s_addr = ifa->ifa_mask;
1064 break; 1068 break;
1065 1069