aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/devinet.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/devinet.c')
-rw-r--r--net/ipv4/devinet.c60
1 files changed, 32 insertions, 28 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 480ace9819f6..ba5e7f4cd127 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -252,7 +252,7 @@ static void __inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
252 252
253 ASSERT_RTNL(); 253 ASSERT_RTNL();
254 254
255 /* 1. Deleting primary ifaddr forces deletion all secondaries 255 /* 1. Deleting primary ifaddr forces deletion all secondaries
256 * unless alias promotion is set 256 * unless alias promotion is set
257 **/ 257 **/
258 258
@@ -260,7 +260,7 @@ static void __inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap,
260 struct in_ifaddr **ifap1 = &ifa1->ifa_next; 260 struct in_ifaddr **ifap1 = &ifa1->ifa_next;
261 261
262 while ((ifa = *ifap1) != NULL) { 262 while ((ifa = *ifap1) != NULL) {
263 if (!(ifa->ifa_flags & IFA_F_SECONDARY) && 263 if (!(ifa->ifa_flags & IFA_F_SECONDARY) &&
264 ifa1->ifa_scope <= ifa->ifa_scope) 264 ifa1->ifa_scope <= ifa->ifa_scope)
265 last_prim = ifa; 265 last_prim = ifa;
266 266
@@ -583,8 +583,8 @@ static __inline__ int inet_abc_len(__be32 addr)
583{ 583{
584 int rc = -1; /* Something else, probably a multicast. */ 584 int rc = -1; /* Something else, probably a multicast. */
585 585
586 if (ZERONET(addr)) 586 if (ZERONET(addr))
587 rc = 0; 587 rc = 0;
588 else { 588 else {
589 __u32 haddr = ntohl(addr); 589 __u32 haddr = ntohl(addr);
590 590
@@ -596,7 +596,7 @@ static __inline__ int inet_abc_len(__be32 addr)
596 rc = 24; 596 rc = 24;
597 } 597 }
598 598
599 return rc; 599 return rc;
600} 600}
601 601
602 602
@@ -1020,29 +1020,29 @@ int unregister_inetaddr_notifier(struct notifier_block *nb)
1020 * alias numbering and to create unique labels if possible. 1020 * alias numbering and to create unique labels if possible.
1021*/ 1021*/
1022static void inetdev_changename(struct net_device *dev, struct in_device *in_dev) 1022static void inetdev_changename(struct net_device *dev, struct in_device *in_dev)
1023{ 1023{
1024 struct in_ifaddr *ifa; 1024 struct in_ifaddr *ifa;
1025 int named = 0; 1025 int named = 0;
1026 1026
1027 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { 1027 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
1028 char old[IFNAMSIZ], *dot; 1028 char old[IFNAMSIZ], *dot;
1029 1029
1030 memcpy(old, ifa->ifa_label, IFNAMSIZ); 1030 memcpy(old, ifa->ifa_label, IFNAMSIZ);
1031 memcpy(ifa->ifa_label, dev->name, IFNAMSIZ); 1031 memcpy(ifa->ifa_label, dev->name, IFNAMSIZ);
1032 if (named++ == 0) 1032 if (named++ == 0)
1033 continue; 1033 continue;
1034 dot = strchr(ifa->ifa_label, ':'); 1034 dot = strchr(ifa->ifa_label, ':');
1035 if (dot == NULL) { 1035 if (dot == NULL) {
1036 sprintf(old, ":%d", named); 1036 sprintf(old, ":%d", named);
1037 dot = old; 1037 dot = old;
1038 } 1038 }
1039 if (strlen(dot) + strlen(dev->name) < IFNAMSIZ) { 1039 if (strlen(dot) + strlen(dev->name) < IFNAMSIZ) {
1040 strcat(ifa->ifa_label, dot); 1040 strcat(ifa->ifa_label, dot);
1041 } else { 1041 } else {
1042 strcpy(ifa->ifa_label + (IFNAMSIZ - strlen(dot) - 1), dot); 1042 strcpy(ifa->ifa_label + (IFNAMSIZ - strlen(dot) - 1), dot);
1043 } 1043 }
1044 } 1044 }
1045} 1045}
1046 1046
1047/* Called only under RTNL semaphore */ 1047/* Called only under RTNL semaphore */
1048 1048
@@ -1140,7 +1140,7 @@ static int inet_fill_ifaddr(struct sk_buff *skb, struct in_ifaddr *ifa,
1140 1140
1141 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*ifm), flags); 1141 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*ifm), flags);
1142 if (nlh == NULL) 1142 if (nlh == NULL)
1143 return -ENOBUFS; 1143 return -EMSGSIZE;
1144 1144
1145 ifm = nlmsg_data(nlh); 1145 ifm = nlmsg_data(nlh);
1146 ifm->ifa_family = AF_INET; 1146 ifm->ifa_family = AF_INET;
@@ -1167,7 +1167,8 @@ static int inet_fill_ifaddr(struct sk_buff *skb, struct in_ifaddr *ifa,
1167 return nlmsg_end(skb, nlh); 1167 return nlmsg_end(skb, nlh);
1168 1168
1169nla_put_failure: 1169nla_put_failure:
1170 return nlmsg_cancel(skb, nlh); 1170 nlmsg_cancel(skb, nlh);
1171 return -EMSGSIZE;
1171} 1172}
1172 1173
1173static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) 1174static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
@@ -1225,9 +1226,12 @@ static void rtmsg_ifa(int event, struct in_ifaddr* ifa, struct nlmsghdr *nlh,
1225 goto errout; 1226 goto errout;
1226 1227
1227 err = inet_fill_ifaddr(skb, ifa, pid, seq, event, 0); 1228 err = inet_fill_ifaddr(skb, ifa, pid, seq, event, 0);
1228 /* failure implies BUG in inet_nlmsg_size() */ 1229 if (err < 0) {
1229 BUG_ON(err < 0); 1230 /* -EMSGSIZE implies BUG in inet_nlmsg_size() */
1230 1231 WARN_ON(err == -EMSGSIZE);
1232 kfree_skb(skb);
1233 goto errout;
1234 }
1231 err = rtnl_notify(skb, pid, RTNLGRP_IPV4_IFADDR, nlh, GFP_KERNEL); 1235 err = rtnl_notify(skb, pid, RTNLGRP_IPV4_IFADDR, nlh, GFP_KERNEL);
1232errout: 1236errout:
1233 if (err < 0) 1237 if (err < 0)
@@ -1535,7 +1539,7 @@ static struct devinet_sysctl_table {
1535 }, 1539 },
1536 }, 1540 },
1537 .devinet_conf_dir = { 1541 .devinet_conf_dir = {
1538 { 1542 {
1539 .ctl_name = NET_IPV4_CONF, 1543 .ctl_name = NET_IPV4_CONF,
1540 .procname = "conf", 1544 .procname = "conf",
1541 .mode = 0555, 1545 .mode = 0555,
@@ -1577,18 +1581,18 @@ static void devinet_sysctl_register(struct in_device *in_dev,
1577 } 1581 }
1578 1582
1579 if (dev) { 1583 if (dev) {
1580 dev_name = dev->name; 1584 dev_name = dev->name;
1581 t->devinet_dev[0].ctl_name = dev->ifindex; 1585 t->devinet_dev[0].ctl_name = dev->ifindex;
1582 } else { 1586 } else {
1583 dev_name = "default"; 1587 dev_name = "default";
1584 t->devinet_dev[0].ctl_name = NET_PROTO_CONF_DEFAULT; 1588 t->devinet_dev[0].ctl_name = NET_PROTO_CONF_DEFAULT;
1585 } 1589 }
1586 1590
1587 /* 1591 /*
1588 * Make a copy of dev_name, because '.procname' is regarded as const 1592 * Make a copy of dev_name, because '.procname' is regarded as const
1589 * by sysctl and we wouldn't want anyone to change it under our feet 1593 * by sysctl and we wouldn't want anyone to change it under our feet
1590 * (see SIOCSIFNAME). 1594 * (see SIOCSIFNAME).
1591 */ 1595 */
1592 dev_name = kstrdup(dev_name, GFP_KERNEL); 1596 dev_name = kstrdup(dev_name, GFP_KERNEL);
1593 if (!dev_name) 1597 if (!dev_name)
1594 goto free; 1598 goto free;