Skip to content

Commit 8c83f2d

Browse files
ssuryaextrdavem330
authored andcommitted
vrf: check accept_source_route on the original netdevice
Configuration check to accept source route IP options should be made on the incoming netdevice when the skb->dev is an l3mdev master. The route lookup for the source route next hop also needs the incoming netdev. v2->v3: - Simplify by passing the original netdevice down the stack (per David Ahern). Signed-off-by: Stephen Suryaputra <ssuryaextr@gmail.com> Reviewed-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8c1074f commit 8c83f2d

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

include/net/ip.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ int ip_options_get_from_user(struct net *net, struct ip_options_rcu **optp,
677677
unsigned char __user *data, int optlen);
678678
void ip_options_undo(struct ip_options *opt);
679679
void ip_forward_options(struct sk_buff *skb);
680-
int ip_options_rcv_srr(struct sk_buff *skb);
680+
int ip_options_rcv_srr(struct sk_buff *skb, struct net_device *dev);
681681

682682
/*
683683
* Functions provided by ip_sockglue.c

net/ipv4/ip_input.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,10 @@ int ip_local_deliver(struct sk_buff *skb)
257257
ip_local_deliver_finish);
258258
}
259259

260-
static inline bool ip_rcv_options(struct sk_buff *skb)
260+
static inline bool ip_rcv_options(struct sk_buff *skb, struct net_device *dev)
261261
{
262262
struct ip_options *opt;
263263
const struct iphdr *iph;
264-
struct net_device *dev = skb->dev;
265264

266265
/* It looks as overkill, because not all
267266
IP options require packet mangling.
@@ -297,7 +296,7 @@ static inline bool ip_rcv_options(struct sk_buff *skb)
297296
}
298297
}
299298

300-
if (ip_options_rcv_srr(skb))
299+
if (ip_options_rcv_srr(skb, dev))
301300
goto drop;
302301
}
303302

@@ -353,7 +352,7 @@ static int ip_rcv_finish_core(struct net *net, struct sock *sk,
353352
}
354353
#endif
355354

356-
if (iph->ihl > 5 && ip_rcv_options(skb))
355+
if (iph->ihl > 5 && ip_rcv_options(skb, dev))
357356
goto drop;
358357

359358
rt = skb_rtable(skb);

net/ipv4/ip_options.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ void ip_forward_options(struct sk_buff *skb)
612612
}
613613
}
614614

615-
int ip_options_rcv_srr(struct sk_buff *skb)
615+
int ip_options_rcv_srr(struct sk_buff *skb, struct net_device *dev)
616616
{
617617
struct ip_options *opt = &(IPCB(skb)->opt);
618618
int srrspace, srrptr;
@@ -647,7 +647,7 @@ int ip_options_rcv_srr(struct sk_buff *skb)
647647

648648
orefdst = skb->_skb_refdst;
649649
skb_dst_set(skb, NULL);
650-
err = ip_route_input(skb, nexthop, iph->saddr, iph->tos, skb->dev);
650+
err = ip_route_input(skb, nexthop, iph->saddr, iph->tos, dev);
651651
rt2 = skb_rtable(skb);
652652
if (err || (rt2->rt_type != RTN_UNICAST && rt2->rt_type != RTN_LOCAL)) {
653653
skb_dst_drop(skb);

0 commit comments

Comments
 (0)