mirror of
https://github.com/torvalds/linux.git
synced 2026-05-05 23:05:25 -04:00
net: ipv4: convert ip_rcv_options to drop reasons
This converts the only path not returning drop reasons in ip_rcv_finish_core. Signed-off-by: Antoine Tenart <atenart@kernel.org> Reviewed-by: David Ahern <dsahern@kernel.org> Link: https://patch.msgid.link/20250915091958.15382-4-atenart@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
dcc0e68ed3
commit
9e1e2f4ebf
@@ -263,10 +263,11 @@ int ip_local_deliver(struct sk_buff *skb)
|
||||
}
|
||||
EXPORT_SYMBOL(ip_local_deliver);
|
||||
|
||||
static inline bool ip_rcv_options(struct sk_buff *skb, struct net_device *dev)
|
||||
static inline enum skb_drop_reason
|
||||
ip_rcv_options(struct sk_buff *skb, struct net_device *dev)
|
||||
{
|
||||
struct ip_options *opt;
|
||||
const struct iphdr *iph;
|
||||
struct ip_options *opt;
|
||||
|
||||
/* It looks as overkill, because not all
|
||||
IP options require packet mangling.
|
||||
@@ -277,7 +278,7 @@ static inline bool ip_rcv_options(struct sk_buff *skb, struct net_device *dev)
|
||||
*/
|
||||
if (skb_cow(skb, skb_headroom(skb))) {
|
||||
__IP_INC_STATS(dev_net(dev), IPSTATS_MIB_INDISCARDS);
|
||||
goto drop;
|
||||
return SKB_DROP_REASON_NOMEM;
|
||||
}
|
||||
|
||||
iph = ip_hdr(skb);
|
||||
@@ -286,7 +287,7 @@ static inline bool ip_rcv_options(struct sk_buff *skb, struct net_device *dev)
|
||||
|
||||
if (ip_options_compile(dev_net(dev), opt, skb)) {
|
||||
__IP_INC_STATS(dev_net(dev), IPSTATS_MIB_INHDRERRORS);
|
||||
goto drop;
|
||||
return SKB_DROP_REASON_IP_INHDR;
|
||||
}
|
||||
|
||||
if (unlikely(opt->srr)) {
|
||||
@@ -298,17 +299,15 @@ static inline bool ip_rcv_options(struct sk_buff *skb, struct net_device *dev)
|
||||
net_info_ratelimited("source route option %pI4 -> %pI4\n",
|
||||
&iph->saddr,
|
||||
&iph->daddr);
|
||||
goto drop;
|
||||
return SKB_DROP_REASON_NOT_SPECIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
if (ip_options_rcv_srr(skb, dev))
|
||||
goto drop;
|
||||
return SKB_DROP_REASON_NOT_SPECIFIED;
|
||||
}
|
||||
|
||||
return false;
|
||||
drop:
|
||||
return true;
|
||||
return SKB_NOT_DROPPED_YET;
|
||||
}
|
||||
|
||||
static bool ip_can_use_hint(const struct sk_buff *skb, const struct iphdr *iph,
|
||||
@@ -388,9 +387,10 @@ static int ip_rcv_finish_core(struct net *net,
|
||||
}
|
||||
#endif
|
||||
|
||||
if (iph->ihl > 5 && ip_rcv_options(skb, dev)) {
|
||||
drop_reason = SKB_DROP_REASON_NOT_SPECIFIED;
|
||||
goto drop;
|
||||
if (iph->ihl > 5) {
|
||||
drop_reason = ip_rcv_options(skb, dev);
|
||||
if (drop_reason)
|
||||
goto drop;
|
||||
}
|
||||
|
||||
rt = skb_rtable(skb);
|
||||
|
||||
Reference in New Issue
Block a user