diff options
author | Jamal Hadi Salim <hadi@cyberus.ca> | 2005-06-19 01:54:12 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-06-19 01:54:12 -0400 |
commit | b6544c0b4cf2bd96195f3cdb7cebfb35090fc557 (patch) | |
tree | 717f69a0c204b12eeedb8035fb66c8e9bb2d5a09 /net/core | |
parent | 1797754ea7ee5e0d859b0a32506ff999f8d5fb71 (diff) |
[NETLINK]: Correctly set NLM_F_MULTI without checking the pid
This patch rectifies some rtnetlink message builders that derive the
flags from the pid. It is now explicit like the other cases
which get it right. Also fixes half a dozen dumpers which did not
set NLM_F_MULTI at all.
Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/neighbour.c | 14 | ||||
-rw-r--r-- | net/core/rtnetlink.c | 13 |
2 files changed, 15 insertions, 12 deletions
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 0fb742e228cc..f6bdcad47da6 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -1859,18 +1859,17 @@ out: | |||
1859 | } | 1859 | } |
1860 | 1860 | ||
1861 | static int neigh_fill_info(struct sk_buff *skb, struct neighbour *n, | 1861 | static int neigh_fill_info(struct sk_buff *skb, struct neighbour *n, |
1862 | u32 pid, u32 seq, int event) | 1862 | u32 pid, u32 seq, int event, unsigned int flags) |
1863 | { | 1863 | { |
1864 | unsigned long now = jiffies; | 1864 | unsigned long now = jiffies; |
1865 | unsigned char *b = skb->tail; | 1865 | unsigned char *b = skb->tail; |
1866 | struct nda_cacheinfo ci; | 1866 | struct nda_cacheinfo ci; |
1867 | int locked = 0; | 1867 | int locked = 0; |
1868 | u32 probes; | 1868 | u32 probes; |
1869 | struct nlmsghdr *nlh = NLMSG_PUT(skb, pid, seq, event, | 1869 | struct nlmsghdr *nlh = NLMSG_NEW(skb, pid, seq, event, |
1870 | sizeof(struct ndmsg)); | 1870 | sizeof(struct ndmsg), flags); |
1871 | struct ndmsg *ndm = NLMSG_DATA(nlh); | 1871 | struct ndmsg *ndm = NLMSG_DATA(nlh); |
1872 | 1872 | ||
1873 | nlh->nlmsg_flags = pid ? NLM_F_MULTI : 0; | ||
1874 | ndm->ndm_family = n->ops->family; | 1873 | ndm->ndm_family = n->ops->family; |
1875 | ndm->ndm_flags = n->flags; | 1874 | ndm->ndm_flags = n->flags; |
1876 | ndm->ndm_type = n->type; | 1875 | ndm->ndm_type = n->type; |
@@ -1920,7 +1919,8 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, | |||
1920 | continue; | 1919 | continue; |
1921 | if (neigh_fill_info(skb, n, NETLINK_CB(cb->skb).pid, | 1920 | if (neigh_fill_info(skb, n, NETLINK_CB(cb->skb).pid, |
1922 | cb->nlh->nlmsg_seq, | 1921 | cb->nlh->nlmsg_seq, |
1923 | RTM_NEWNEIGH) <= 0) { | 1922 | RTM_NEWNEIGH, |
1923 | NLM_F_MULTI) <= 0) { | ||
1924 | read_unlock_bh(&tbl->lock); | 1924 | read_unlock_bh(&tbl->lock); |
1925 | rc = -1; | 1925 | rc = -1; |
1926 | goto out; | 1926 | goto out; |
@@ -2329,7 +2329,7 @@ void neigh_app_ns(struct neighbour *n) | |||
2329 | if (!skb) | 2329 | if (!skb) |
2330 | return; | 2330 | return; |
2331 | 2331 | ||
2332 | if (neigh_fill_info(skb, n, 0, 0, RTM_GETNEIGH) < 0) { | 2332 | if (neigh_fill_info(skb, n, 0, 0, RTM_GETNEIGH, 0) < 0) { |
2333 | kfree_skb(skb); | 2333 | kfree_skb(skb); |
2334 | return; | 2334 | return; |
2335 | } | 2335 | } |
@@ -2348,7 +2348,7 @@ static void neigh_app_notify(struct neighbour *n) | |||
2348 | if (!skb) | 2348 | if (!skb) |
2349 | return; | 2349 | return; |
2350 | 2350 | ||
2351 | if (neigh_fill_info(skb, n, 0, 0, RTM_NEWNEIGH) < 0) { | 2351 | if (neigh_fill_info(skb, n, 0, 0, RTM_NEWNEIGH, 0) < 0) { |
2352 | kfree_skb(skb); | 2352 | kfree_skb(skb); |
2353 | return; | 2353 | return; |
2354 | } | 2354 | } |
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 56a20f014b8a..63bd88665182 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -178,14 +178,14 @@ rtattr_failure: | |||
178 | 178 | ||
179 | 179 | ||
180 | static int rtnetlink_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, | 180 | static int rtnetlink_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, |
181 | int type, u32 pid, u32 seq, u32 change) | 181 | int type, u32 pid, u32 seq, u32 change, |
182 | unsigned int flags) | ||
182 | { | 183 | { |
183 | struct ifinfomsg *r; | 184 | struct ifinfomsg *r; |
184 | struct nlmsghdr *nlh; | 185 | struct nlmsghdr *nlh; |
185 | unsigned char *b = skb->tail; | 186 | unsigned char *b = skb->tail; |
186 | 187 | ||
187 | nlh = NLMSG_PUT(skb, pid, seq, type, sizeof(*r)); | 188 | nlh = NLMSG_NEW(skb, pid, seq, type, sizeof(*r), flags); |
188 | if (pid) nlh->nlmsg_flags |= NLM_F_MULTI; | ||
189 | r = NLMSG_DATA(nlh); | 189 | r = NLMSG_DATA(nlh); |
190 | r->ifi_family = AF_UNSPEC; | 190 | r->ifi_family = AF_UNSPEC; |
191 | r->ifi_type = dev->type; | 191 | r->ifi_type = dev->type; |
@@ -275,7 +275,10 @@ static int rtnetlink_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *c | |||
275 | for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) { | 275 | for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) { |
276 | if (idx < s_idx) | 276 | if (idx < s_idx) |
277 | continue; | 277 | continue; |
278 | if (rtnetlink_fill_ifinfo(skb, dev, RTM_NEWLINK, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq, 0) <= 0) | 278 | if (rtnetlink_fill_ifinfo(skb, dev, RTM_NEWLINK, |
279 | NETLINK_CB(cb->skb).pid, | ||
280 | cb->nlh->nlmsg_seq, 0, | ||
281 | NLM_F_MULTI) <= 0) | ||
279 | break; | 282 | break; |
280 | } | 283 | } |
281 | read_unlock(&dev_base_lock); | 284 | read_unlock(&dev_base_lock); |
@@ -449,7 +452,7 @@ void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change) | |||
449 | if (!skb) | 452 | if (!skb) |
450 | return; | 453 | return; |
451 | 454 | ||
452 | if (rtnetlink_fill_ifinfo(skb, dev, type, 0, 0, change) < 0) { | 455 | if (rtnetlink_fill_ifinfo(skb, dev, type, 0, 0, change, 0) < 0) { |
453 | kfree_skb(skb); | 456 | kfree_skb(skb); |
454 | return; | 457 | return; |
455 | } | 458 | } |