/* that should never happen */ if (skb->pkt_type != PACKET_HOST) goto drop;
if (unlikely(skb->sk)) goto drop;
if (skb_warn_if_lro(skb)) goto drop;
if (!xfrm4_policy_check(NULL, XFRM_POLICY_FWD, skb)) goto drop;
if (IPCB(skb)->opt.router_alert && ip_call_ra_chain(skb)) return NET_RX_SUCCESS;
skb_forward_csum(skb); net = dev_net(skb->dev);
/* * According to the RFC, we must first decrease the TTL field. If * that reaches zero, we must reply an ICMP control message telling * that the packet's lifetime expired. */ if (ip_hdr(skb)->ttl <= 1) goto too_many_hops;
if (!xfrm4_route_forward(skb)) goto drop;
rt = skb_rtable(skb);
if (opt->is_strictroute && rt->rt_uses_gateway) goto sr_failed;
IPCB(skb)->flags |= IPSKB_FORWARDED; mtu = ip_dst_mtu_maybe_forward(&rt->dst, true); if (ip_exceeds_mtu(skb, mtu)) { IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS); icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu)); goto drop; }
/* We are about to mangle packet. Copy it! */ if (skb_cow(skb, LL_RESERVED_SPACE(rt->dst.dev)+rt->dst.header_len)) goto drop; iph = ip_hdr(skb);
/* Decrease ttl after skb cow done */ ip_decrease_ttl(iph);
/* * We now generate an ICMP HOST REDIRECT giving the route * we calculated. */ if (IPCB(skb)->flags & IPSKB_DOREDIRECT && !opt->srr && !skb_sec_path(skb)) ip_rt_send_redirect(skb);
if (net->ipv4.sysctl_ip_fwd_update_priority) skb->priority = rt_tos2priority(iph->tos);
/* if egress device is enslaved to an L3 master device pass the * skb to its handler for processing */ skb = l3mdev_ip_out(sk, skb); if (unlikely(!skb)) return0;