aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2006-08-22 03:01:27 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-22 17:55:13 -0400
commit2d7202bfdd28687073f5efef8d2f51bbab0af867 (patch)
treecde1c82c196c353658fc7ede31ea153a306ed7f9 /net/core
parent86872cb57925c46a6499887d77afb880a892c0ec (diff)
[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')
-rw-r--r--net/core/rtnetlink.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index dfc58269240a..eeff0b23e944 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -188,22 +188,27 @@ void rtnl_set_sk_err(u32 group, int error)
188 188
189int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics) 189int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics)
190{ 190{
191 struct rtattr *mx = (struct rtattr*)skb->tail; 191 struct nlattr *mx;
192 int i; 192 int i, valid = 0;
193
194 mx = nla_nest_start(skb, RTA_METRICS);
195 if (mx == NULL)
196 return -ENOBUFS;
193 197
194 RTA_PUT(skb, RTA_METRICS, 0, NULL); 198 for (i = 0; i < RTAX_MAX; i++) {
195 for (i=0; i<RTAX_MAX; i++) { 199 if (metrics[i]) {
196 if (metrics[i]) 200 valid++;
197 RTA_PUT(skb, i+1, sizeof(u32), metrics+i); 201 NLA_PUT_U32(skb, i+1, metrics[i]);
202 }
198 } 203 }
199 mx->rta_len = skb->tail - (u8*)mx;
200 if (mx->rta_len == RTA_LENGTH(0))
201 skb_trim(skb, (u8*)mx - skb->data);
202 return 0;
203 204
204rtattr_failure: 205 if (!valid)
205 skb_trim(skb, (u8*)mx - skb->data); 206 goto nla_put_failure;
206 return -1; 207
208 return nla_nest_end(skb, mx);
209
210nla_put_failure:
211 return nla_nest_cancel(skb, mx);
207} 212}
208 213
209 214