diff options
author | Thomas Graf <tgraf@suug.ch> | 2006-08-22 00:01:27 -0700 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-09-22 14:55:13 -0700 |
commit | 2d7202bfdd28687073f5efef8d2f51bbab0af867 (patch) | |
tree | cde1c82c196c353658fc7ede31ea153a306ed7f9 /net/core/rtnetlink.c | |
parent | 86872cb57925c46a6499887d77afb880a892c0ec (diff) | |
download | kernel_samsung_smdk4412-2d7202bfdd28687073f5efef8d2f51bbab0af867.zip kernel_samsung_smdk4412-2d7202bfdd28687073f5efef8d2f51bbab0af867.tar.gz kernel_samsung_smdk4412-2d7202bfdd28687073f5efef8d2f51bbab0af867.tar.bz2 |
[IPv6] route: Convert FIB6 dumping to use new netlink api
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/rtnetlink.c')
-rw-r--r-- | net/core/rtnetlink.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index dfc5826..eeff0b2 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -188,22 +188,27 @@ void rtnl_set_sk_err(u32 group, int error) int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics) { - struct rtattr *mx = (struct rtattr*)skb->tail; - int i; + struct nlattr *mx; + int i, valid = 0; + + mx = nla_nest_start(skb, RTA_METRICS); + if (mx == NULL) + return -ENOBUFS; - RTA_PUT(skb, RTA_METRICS, 0, NULL); - for (i=0; i<RTAX_MAX; i++) { - if (metrics[i]) - RTA_PUT(skb, i+1, sizeof(u32), metrics+i); + for (i = 0; i < RTAX_MAX; i++) { + if (metrics[i]) { + valid++; + NLA_PUT_U32(skb, i+1, metrics[i]); + } } - mx->rta_len = skb->tail - (u8*)mx; - if (mx->rta_len == RTA_LENGTH(0)) - skb_trim(skb, (u8*)mx - skb->data); - return 0; -rtattr_failure: - skb_trim(skb, (u8*)mx - skb->data); - return -1; + if (!valid) + goto nla_put_failure; + + return nla_nest_end(skb, mx); + +nla_put_failure: + return nla_nest_cancel(skb, mx); } |