aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2006-08-05 02:04:36 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-22 17:53:46 -0400
commit47f68512d2685431f1781830dfcbab31bda87644 (patch)
tree3bf7335dd213ac1a51f497ee1f0c2ea49a26820a /net
parentdfdd5fd4e93d98e06be9ac9db84e3b98c6c26706 (diff)
[IPV4]: Convert address dumping to new netlink api
Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/devinet.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 309640e9ede1..80bf5b2ea2e6 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1112,32 +1112,37 @@ static int inet_fill_ifaddr(struct sk_buff *skb, struct in_ifaddr *ifa,
1112{ 1112{
1113 struct ifaddrmsg *ifm; 1113 struct ifaddrmsg *ifm;
1114 struct nlmsghdr *nlh; 1114 struct nlmsghdr *nlh;
1115 unsigned char *b = skb->tail;
1116 1115
1117 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*ifm), flags); 1116 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*ifm), flags);
1118 ifm = NLMSG_DATA(nlh); 1117 if (nlh == NULL)
1118 return -ENOBUFS;
1119
1120 ifm = nlmsg_data(nlh);
1119 ifm->ifa_family = AF_INET; 1121 ifm->ifa_family = AF_INET;
1120 ifm->ifa_prefixlen = ifa->ifa_prefixlen; 1122 ifm->ifa_prefixlen = ifa->ifa_prefixlen;
1121 ifm->ifa_flags = ifa->ifa_flags|IFA_F_PERMANENT; 1123 ifm->ifa_flags = ifa->ifa_flags|IFA_F_PERMANENT;
1122 ifm->ifa_scope = ifa->ifa_scope; 1124 ifm->ifa_scope = ifa->ifa_scope;
1123 ifm->ifa_index = ifa->ifa_dev->dev->ifindex; 1125 ifm->ifa_index = ifa->ifa_dev->dev->ifindex;
1126
1124 if (ifa->ifa_address) 1127 if (ifa->ifa_address)
1125 RTA_PUT(skb, IFA_ADDRESS, 4, &ifa->ifa_address); 1128 NLA_PUT_U32(skb, IFA_ADDRESS, ifa->ifa_address);
1129
1126 if (ifa->ifa_local) 1130 if (ifa->ifa_local)
1127 RTA_PUT(skb, IFA_LOCAL, 4, &ifa->ifa_local); 1131 NLA_PUT_U32(skb, IFA_LOCAL, ifa->ifa_local);
1132
1128 if (ifa->ifa_broadcast) 1133 if (ifa->ifa_broadcast)
1129 RTA_PUT(skb, IFA_BROADCAST, 4, &ifa->ifa_broadcast); 1134 NLA_PUT_U32(skb, IFA_BROADCAST, ifa->ifa_broadcast);
1135
1130 if (ifa->ifa_anycast) 1136 if (ifa->ifa_anycast)
1131 RTA_PUT(skb, IFA_ANYCAST, 4, &ifa->ifa_anycast); 1137 NLA_PUT_U32(skb, IFA_ANYCAST, ifa->ifa_anycast);
1138
1132 if (ifa->ifa_label[0]) 1139 if (ifa->ifa_label[0])
1133 RTA_PUT(skb, IFA_LABEL, IFNAMSIZ, &ifa->ifa_label); 1140 NLA_PUT_STRING(skb, IFA_LABEL, ifa->ifa_label);
1134 nlh->nlmsg_len = skb->tail - b; 1141
1135 return skb->len; 1142 return nlmsg_end(skb, nlh);
1136 1143
1137nlmsg_failure: 1144nla_put_failure:
1138rtattr_failure: 1145 return nlmsg_cancel(skb, nlh);
1139 skb_trim(skb, b - skb->data);
1140 return -1;
1141} 1146}
1142 1147
1143static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) 1148static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
@@ -1185,17 +1190,16 @@ done:
1185 1190
1186static void rtmsg_ifa(int event, struct in_ifaddr* ifa) 1191static void rtmsg_ifa(int event, struct in_ifaddr* ifa)
1187{ 1192{
1188 int size = NLMSG_SPACE(sizeof(struct ifaddrmsg) + 128); 1193 struct sk_buff *skb;
1189 struct sk_buff *skb = alloc_skb(size, GFP_KERNEL);
1190 1194
1191 if (!skb) 1195 skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
1196 if (skb == NULL)
1192 netlink_set_err(rtnl, 0, RTNLGRP_IPV4_IFADDR, ENOBUFS); 1197 netlink_set_err(rtnl, 0, RTNLGRP_IPV4_IFADDR, ENOBUFS);
1193 else if (inet_fill_ifaddr(skb, ifa, 0, 0, event, 0) < 0) { 1198 else if (inet_fill_ifaddr(skb, ifa, 0, 0, event, 0) < 0) {
1194 kfree_skb(skb); 1199 kfree_skb(skb);
1195 netlink_set_err(rtnl, 0, RTNLGRP_IPV4_IFADDR, EINVAL); 1200 netlink_set_err(rtnl, 0, RTNLGRP_IPV4_IFADDR, EINVAL);
1196 } else { 1201 } else
1197 netlink_broadcast(rtnl, skb, 0, RTNLGRP_IPV4_IFADDR, GFP_KERNEL); 1202 netlink_broadcast(rtnl, skb, 0, RTNLGRP_IPV4_IFADDR, GFP_KERNEL);
1198 }
1199} 1203}
1200 1204
1201static struct rtnetlink_link inet_rtnetlink_table[RTM_NR_MSGTYPES] = { 1205static struct rtnetlink_link inet_rtnetlink_table[RTM_NR_MSGTYPES] = {