aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ipmr.c
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2012-06-26 19:36:13 -0400
committerDavid S. Miller <davem@davemloft.net>2012-06-27 18:36:44 -0400
commit92a395e52f0c97f38ff675d7c698404bfc812dc2 (patch)
tree3ee607b55fa653baa2657ece29f99c224ab0e3ec /net/ipv4/ipmr.c
parent6e277ed59a45544786f4c4643a69527138c24fc1 (diff)
ipmr: Do not use RTA_PUT() macros
Also fix a needless skb tailroom check for a 4 bytes area after after each rtnexthop block. Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ipmr.c')
-rw-r--r--net/ipv4/ipmr.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index c94bbc6f2ba3..b4ac39f11d19 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -2006,37 +2006,37 @@ static int __ipmr_fill_mroute(struct mr_table *mrt, struct sk_buff *skb,
2006{ 2006{
2007 int ct; 2007 int ct;
2008 struct rtnexthop *nhp; 2008 struct rtnexthop *nhp;
2009 u8 *b = skb_tail_pointer(skb); 2009 struct nlattr *mp_attr;
2010 struct rtattr *mp_head;
2011 2010
2012 /* If cache is unresolved, don't try to parse IIF and OIF */ 2011 /* If cache is unresolved, don't try to parse IIF and OIF */
2013 if (c->mfc_parent >= MAXVIFS) 2012 if (c->mfc_parent >= MAXVIFS)
2014 return -ENOENT; 2013 return -ENOENT;
2015 2014
2016 if (VIF_EXISTS(mrt, c->mfc_parent)) 2015 if (VIF_EXISTS(mrt, c->mfc_parent) &&
2017 RTA_PUT(skb, RTA_IIF, 4, &mrt->vif_table[c->mfc_parent].dev->ifindex); 2016 nla_put_u32(skb, RTA_IIF, mrt->vif_table[c->mfc_parent].dev->ifindex) < 0)
2017 return -EMSGSIZE;
2018 2018
2019 mp_head = (struct rtattr *)skb_put(skb, RTA_LENGTH(0)); 2019 if (!(mp_attr = nla_nest_start(skb, RTA_MULTIPATH)))
2020 return -EMSGSIZE;
2020 2021
2021 for (ct = c->mfc_un.res.minvif; ct < c->mfc_un.res.maxvif; ct++) { 2022 for (ct = c->mfc_un.res.minvif; ct < c->mfc_un.res.maxvif; ct++) {
2022 if (VIF_EXISTS(mrt, ct) && c->mfc_un.res.ttls[ct] < 255) { 2023 if (VIF_EXISTS(mrt, ct) && c->mfc_un.res.ttls[ct] < 255) {
2023 if (skb_tailroom(skb) < RTA_ALIGN(RTA_ALIGN(sizeof(*nhp)) + 4)) 2024 if (!(nhp = nla_reserve_nohdr(skb, sizeof(*nhp)))) {
2024 goto rtattr_failure; 2025 nla_nest_cancel(skb, mp_attr);
2025 nhp = (struct rtnexthop *)skb_put(skb, RTA_ALIGN(sizeof(*nhp))); 2026 return -EMSGSIZE;
2027 }
2028
2026 nhp->rtnh_flags = 0; 2029 nhp->rtnh_flags = 0;
2027 nhp->rtnh_hops = c->mfc_un.res.ttls[ct]; 2030 nhp->rtnh_hops = c->mfc_un.res.ttls[ct];
2028 nhp->rtnh_ifindex = mrt->vif_table[ct].dev->ifindex; 2031 nhp->rtnh_ifindex = mrt->vif_table[ct].dev->ifindex;
2029 nhp->rtnh_len = sizeof(*nhp); 2032 nhp->rtnh_len = sizeof(*nhp);
2030 } 2033 }
2031 } 2034 }
2032 mp_head->rta_type = RTA_MULTIPATH; 2035
2033 mp_head->rta_len = skb_tail_pointer(skb) - (u8 *)mp_head; 2036 nla_nest_end(skb, mp_attr);
2037
2034 rtm->rtm_type = RTN_MULTICAST; 2038 rtm->rtm_type = RTN_MULTICAST;
2035 return 1; 2039 return 1;
2036
2037rtattr_failure:
2038 nlmsg_trim(skb, b);
2039 return -EMSGSIZE;
2040} 2040}
2041 2041
2042int ipmr_get_route(struct net *net, struct sk_buff *skb, 2042int ipmr_get_route(struct net *net, struct sk_buff *skb,