Skip to content

Commit ea7a808

Browse files
David Aherndavem330
authored andcommitted
net: lwtunnel: Handle lwtunnel_fill_encap failure
Handle failure in lwtunnel_fill_encap adding attributes to skb. Fixes: 571e722 ("ipv4: support for fib route lwtunnel encap attributes") Fixes: 19e42e4 ("ipv6: support for fib route lwtunnel encap attributes") Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 18a3ed5 commit ea7a808

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

net/ipv4/fib_semantics.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,8 +1279,9 @@ int fib_dump_info(struct sk_buff *skb, u32 portid, u32 seq, int event,
12791279
nla_put_u32(skb, RTA_FLOW, fi->fib_nh[0].nh_tclassid))
12801280
goto nla_put_failure;
12811281
#endif
1282-
if (fi->fib_nh->nh_lwtstate)
1283-
lwtunnel_fill_encap(skb, fi->fib_nh->nh_lwtstate);
1282+
if (fi->fib_nh->nh_lwtstate &&
1283+
lwtunnel_fill_encap(skb, fi->fib_nh->nh_lwtstate) < 0)
1284+
goto nla_put_failure;
12841285
}
12851286
#ifdef CONFIG_IP_ROUTE_MULTIPATH
12861287
if (fi->fib_nhs > 1) {
@@ -1316,8 +1317,10 @@ int fib_dump_info(struct sk_buff *skb, u32 portid, u32 seq, int event,
13161317
nla_put_u32(skb, RTA_FLOW, nh->nh_tclassid))
13171318
goto nla_put_failure;
13181319
#endif
1319-
if (nh->nh_lwtstate)
1320-
lwtunnel_fill_encap(skb, nh->nh_lwtstate);
1320+
if (nh->nh_lwtstate &&
1321+
lwtunnel_fill_encap(skb, nh->nh_lwtstate) < 0)
1322+
goto nla_put_failure;
1323+
13211324
/* length of rtnetlink header + attributes */
13221325
rtnh->rtnh_len = nlmsg_get_pos(skb) - (void *) rtnh;
13231326
} endfor_nexthops(fi);

net/ipv6/route.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3317,7 +3317,8 @@ static int rt6_fill_node(struct net *net,
33173317
if (nla_put_u8(skb, RTA_PREF, IPV6_EXTRACT_PREF(rt->rt6i_flags)))
33183318
goto nla_put_failure;
33193319

3320-
lwtunnel_fill_encap(skb, rt->dst.lwtstate);
3320+
if (lwtunnel_fill_encap(skb, rt->dst.lwtstate) < 0)
3321+
goto nla_put_failure;
33213322

33223323
nlmsg_end(skb, nlh);
33233324
return 0;

0 commit comments

Comments
 (0)