mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2024-12-29 17:23:36 +00:00
net: ip: make ip_route_input() return drop reasons
In this commit, we make ip_route_input() return skb drop reasons that come from ip_route_input_noref(). Meanwhile, adjust all the call to it. Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
82d9983ebe
commit
50038bf38e
@ -210,8 +210,9 @@ int ip_route_use_hint(struct sk_buff *skb, __be32 daddr, __be32 saddr,
|
|||||||
dscp_t dscp, struct net_device *dev,
|
dscp_t dscp, struct net_device *dev,
|
||||||
const struct sk_buff *hint);
|
const struct sk_buff *hint);
|
||||||
|
|
||||||
static inline int ip_route_input(struct sk_buff *skb, __be32 dst, __be32 src,
|
static inline enum skb_drop_reason
|
||||||
dscp_t dscp, struct net_device *devin)
|
ip_route_input(struct sk_buff *skb, __be32 dst, __be32 src, dscp_t dscp,
|
||||||
|
struct net_device *devin)
|
||||||
{
|
{
|
||||||
enum skb_drop_reason reason;
|
enum skb_drop_reason reason;
|
||||||
|
|
||||||
@ -224,7 +225,7 @@ static inline int ip_route_input(struct sk_buff *skb, __be32 dst, __be32 src,
|
|||||||
}
|
}
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
|
|
||||||
return reason ? -EINVAL : 0;
|
return reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ipv4_update_pmtu(struct sk_buff *skb, struct net *net, u32 mtu, int oif,
|
void ipv4_update_pmtu(struct sk_buff *skb, struct net *net, u32 mtu, int oif,
|
||||||
|
@ -373,8 +373,8 @@ static int br_nf_pre_routing_finish(struct net *net, struct sock *sk, struct sk_
|
|||||||
struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
|
struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
|
||||||
struct net_device *dev = skb->dev, *br_indev;
|
struct net_device *dev = skb->dev, *br_indev;
|
||||||
const struct iphdr *iph = ip_hdr(skb);
|
const struct iphdr *iph = ip_hdr(skb);
|
||||||
|
enum skb_drop_reason reason;
|
||||||
struct rtable *rt;
|
struct rtable *rt;
|
||||||
int err;
|
|
||||||
|
|
||||||
br_indev = nf_bridge_get_physindev(skb, net);
|
br_indev = nf_bridge_get_physindev(skb, net);
|
||||||
if (!br_indev) {
|
if (!br_indev) {
|
||||||
@ -390,9 +390,9 @@ static int br_nf_pre_routing_finish(struct net *net, struct sock *sk, struct sk_
|
|||||||
}
|
}
|
||||||
nf_bridge->in_prerouting = 0;
|
nf_bridge->in_prerouting = 0;
|
||||||
if (br_nf_ipv4_daddr_was_changed(skb, nf_bridge)) {
|
if (br_nf_ipv4_daddr_was_changed(skb, nf_bridge)) {
|
||||||
err = ip_route_input(skb, iph->daddr, iph->saddr,
|
reason = ip_route_input(skb, iph->daddr, iph->saddr,
|
||||||
ip4h_dscp(iph), dev);
|
ip4h_dscp(iph), dev);
|
||||||
if (err) {
|
if (reason) {
|
||||||
struct in_device *in_dev = __in_dev_get_rcu(dev);
|
struct in_device *in_dev = __in_dev_get_rcu(dev);
|
||||||
|
|
||||||
/* If err equals -EHOSTUNREACH the error is due to a
|
/* If err equals -EHOSTUNREACH the error is due to a
|
||||||
@ -402,7 +402,8 @@ static int br_nf_pre_routing_finish(struct net *net, struct sock *sk, struct sk_
|
|||||||
* martian destinations: loopback destinations and destination
|
* martian destinations: loopback destinations and destination
|
||||||
* 0.0.0.0. In both cases the packet will be dropped because the
|
* 0.0.0.0. In both cases the packet will be dropped because the
|
||||||
* destination is the loopback device and not the bridge. */
|
* destination is the loopback device and not the bridge. */
|
||||||
if (err != -EHOSTUNREACH || !in_dev || IN_DEV_FORWARD(in_dev))
|
if (reason != SKB_DROP_REASON_IP_INADDRERRORS || !in_dev ||
|
||||||
|
IN_DEV_FORWARD(in_dev))
|
||||||
goto free_skb;
|
goto free_skb;
|
||||||
|
|
||||||
rt = ip_route_output(net, iph->daddr, 0,
|
rt = ip_route_output(net, iph->daddr, 0,
|
||||||
|
@ -545,7 +545,7 @@ static struct rtable *icmp_route_lookup(struct net *net, struct flowi4 *fl4,
|
|||||||
orefdst = skb_in->_skb_refdst; /* save old refdst */
|
orefdst = skb_in->_skb_refdst; /* save old refdst */
|
||||||
skb_dst_set(skb_in, NULL);
|
skb_dst_set(skb_in, NULL);
|
||||||
err = ip_route_input(skb_in, fl4_dec.daddr, fl4_dec.saddr,
|
err = ip_route_input(skb_in, fl4_dec.daddr, fl4_dec.saddr,
|
||||||
dscp, rt2->dst.dev);
|
dscp, rt2->dst.dev) ? -EINVAL : 0;
|
||||||
|
|
||||||
dst_release(&rt2->dst);
|
dst_release(&rt2->dst);
|
||||||
rt2 = skb_rtable(skb_in);
|
rt2 = skb_rtable(skb_in);
|
||||||
|
@ -618,7 +618,7 @@ int ip_options_rcv_srr(struct sk_buff *skb, struct net_device *dev)
|
|||||||
orefdst = skb->_skb_refdst;
|
orefdst = skb->_skb_refdst;
|
||||||
skb_dst_set(skb, NULL);
|
skb_dst_set(skb, NULL);
|
||||||
err = ip_route_input(skb, nexthop, iph->saddr, ip4h_dscp(iph),
|
err = ip_route_input(skb, nexthop, iph->saddr, ip4h_dscp(iph),
|
||||||
dev);
|
dev) ? -EINVAL : 0;
|
||||||
rt2 = skb_rtable(skb);
|
rt2 = skb_rtable(skb);
|
||||||
if (err || (rt2->rt_type != RTN_UNICAST && rt2->rt_type != RTN_LOCAL)) {
|
if (err || (rt2->rt_type != RTN_UNICAST && rt2->rt_type != RTN_LOCAL)) {
|
||||||
skb_dst_drop(skb);
|
skb_dst_drop(skb);
|
||||||
|
@ -954,10 +954,10 @@ static int input_action_end_dx4_finish(struct net *net, struct sock *sk,
|
|||||||
struct sk_buff *skb)
|
struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
struct dst_entry *orig_dst = skb_dst(skb);
|
struct dst_entry *orig_dst = skb_dst(skb);
|
||||||
|
enum skb_drop_reason reason;
|
||||||
struct seg6_local_lwt *slwt;
|
struct seg6_local_lwt *slwt;
|
||||||
struct iphdr *iph;
|
struct iphdr *iph;
|
||||||
__be32 nhaddr;
|
__be32 nhaddr;
|
||||||
int err;
|
|
||||||
|
|
||||||
slwt = seg6_local_lwtunnel(orig_dst->lwtstate);
|
slwt = seg6_local_lwtunnel(orig_dst->lwtstate);
|
||||||
|
|
||||||
@ -967,9 +967,9 @@ static int input_action_end_dx4_finish(struct net *net, struct sock *sk,
|
|||||||
|
|
||||||
skb_dst_drop(skb);
|
skb_dst_drop(skb);
|
||||||
|
|
||||||
err = ip_route_input(skb, nhaddr, iph->saddr, 0, skb->dev);
|
reason = ip_route_input(skb, nhaddr, iph->saddr, 0, skb->dev);
|
||||||
if (err) {
|
if (reason) {
|
||||||
kfree_skb(skb);
|
kfree_skb_reason(skb, reason);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1174,8 +1174,8 @@ static struct sk_buff *end_dt_vrf_core(struct sk_buff *skb,
|
|||||||
static int input_action_end_dt4(struct sk_buff *skb,
|
static int input_action_end_dt4(struct sk_buff *skb,
|
||||||
struct seg6_local_lwt *slwt)
|
struct seg6_local_lwt *slwt)
|
||||||
{
|
{
|
||||||
|
enum skb_drop_reason reason;
|
||||||
struct iphdr *iph;
|
struct iphdr *iph;
|
||||||
int err;
|
|
||||||
|
|
||||||
if (!decap_and_validate(skb, IPPROTO_IPIP))
|
if (!decap_and_validate(skb, IPPROTO_IPIP))
|
||||||
goto drop;
|
goto drop;
|
||||||
@ -1193,8 +1193,8 @@ static int input_action_end_dt4(struct sk_buff *skb,
|
|||||||
|
|
||||||
iph = ip_hdr(skb);
|
iph = ip_hdr(skb);
|
||||||
|
|
||||||
err = ip_route_input(skb, iph->daddr, iph->saddr, 0, skb->dev);
|
reason = ip_route_input(skb, iph->daddr, iph->saddr, 0, skb->dev);
|
||||||
if (unlikely(err))
|
if (unlikely(reason))
|
||||||
goto drop;
|
goto drop;
|
||||||
|
|
||||||
return dst_input(skb);
|
return dst_input(skb);
|
||||||
|
Loading…
Reference in New Issue
Block a user