Release 4.11 net/ipv4/ip_output.c
/*
* INET An implementation of the TCP/IP protocol suite for the LINUX
* operating system. INET is implemented using the BSD Socket
* interface as the means of communication with the user level.
*
* The Internet Protocol (IP) output module.
*
* Authors: Ross Biro
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
* Donald Becker, <becker@super.org>
* Alan Cox, <Alan.Cox@linux.org>
* Richard Underwood
* Stefan Becker, <stefanb@yello.ping.de>
* Jorge Cwik, <jorge@laser.satlink.net>
* Arnt Gulbrandsen, <agulbra@nvg.unit.no>
* Hirokazu Takahashi, <taka@valinux.co.jp>
*
* See ip_input.c for original log
*
* Fixes:
* Alan Cox : Missing nonblock feature in ip_build_xmit.
* Mike Kilburn : htons() missing in ip_build_xmit.
* Bradford Johnson: Fix faulty handling of some frames when
* no route is found.
* Alexander Demenshin: Missing sk/skb free in ip_queue_xmit
* (in case if packet not accepted by
* output firewall rules)
* Mike McLagan : Routing by source
* Alexey Kuznetsov: use new route cache
* Andi Kleen: Fix broken PMTU recovery and remove
* some redundant tests.
* Vitaly E. Lavrov : Transparent proxy revived after year coma.
* Andi Kleen : Replace ip_reply with ip_send_reply.
* Andi Kleen : Split fast and slow ip_build_xmit path
* for decreased register pressure on x86
* and more readibility.
* Marc Boucher : When call_out_firewall returns FW_QUEUE,
* silently drop skb instead of failing with -EPERM.
* Detlev Wengorz : Copy protocol for fragments.
* Hirokazu Takahashi: HW checksumming for outgoing UDP
* datagrams.
* Hirokazu Takahashi: sendfile() on UDP works now.
*/
#include <linux/uaccess.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/highmem.h>
#include <linux/slab.h>
#include <linux/socket.h>
#include <linux/sockios.h>
#include <linux/in.h>
#include <linux/inet.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/proc_fs.h>
#include <linux/stat.h>
#include <linux/init.h>
#include <net/snmp.h>
#include <net/ip.h>
#include <net/protocol.h>
#include <net/route.h>
#include <net/xfrm.h>
#include <linux/skbuff.h>
#include <net/sock.h>
#include <net/arp.h>
#include <net/icmp.h>
#include <net/checksum.h>
#include <net/inetpeer.h>
#include <net/lwtunnel.h>
#include <linux/bpf-cgroup.h>
#include <linux/igmp.h>
#include <linux/netfilter_ipv4.h>
#include <linux/netfilter_bridge.h>
#include <linux/netlink.h>
#include <linux/tcp.h>
static int
ip_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
unsigned int mtu,
int (*output)(struct net *, struct sock *, struct sk_buff *));
/* Generate a checksum for an outgoing IP datagram. */
void ip_send_check(struct iphdr *iph)
{
iph->check = 0;
iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 34 | 100.00% | 1 | 100.00% |
Total | 34 | 100.00% | 1 | 100.00% |
EXPORT_SYMBOL(ip_send_check);
int __ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb)
{
struct iphdr *iph = ip_hdr(skb);
iph->tot_len = htons(skb->len);
ip_send_check(iph);
/* 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))
return 0;
skb->protocol = htons(ETH_P_IP);
return nf_hook(NFPROTO_IPV4, NF_INET_LOCAL_OUT,
net, sk, skb, NULL, skb_dst(skb)->dev,
dst_output);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 47 | 46.53% | 1 | 9.09% |
David Ahern | 21 | 20.79% | 1 | 9.09% |
David S. Miller | 10 | 9.90% | 1 | 9.09% |
Eli Cooper | 9 | 8.91% | 1 | 9.09% |
Eric W. Biedermann | 9 | 8.91% | 4 | 36.36% |
Eric Dumazet | 3 | 2.97% | 1 | 9.09% |
Jan Engelhardt | 1 | 0.99% | 1 | 9.09% |
Patrick McHardy | 1 | 0.99% | 1 | 9.09% |
Total | 101 | 100.00% | 11 | 100.00% |
int ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb)
{
int err;
err = __ip_local_out(net, sk, skb);
if (likely(err == 1))
err = dst_output(net, sk, skb);
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 36 | 63.16% | 1 | 11.11% |
Eric W. Biedermann | 14 | 24.56% | 7 | 77.78% |
Eric Dumazet | 7 | 12.28% | 1 | 11.11% |
Total | 57 | 100.00% | 9 | 100.00% |
EXPORT_SYMBOL_GPL(ip_local_out);
static inline int ip_select_ttl(struct inet_sock *inet, struct dst_entry *dst)
{
int ttl = inet->uc_ttl;
if (ttl < 0)
ttl = ip4_dst_hoplimit(dst);
return ttl;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
David S. Miller | 39 | 97.50% | 2 | 66.67% |
Arnaldo Carvalho de Melo | 1 | 2.50% | 1 | 33.33% |
Total | 40 | 100.00% | 3 | 100.00% |
/*
* Add an ip header to a skbuff and send it out.
*
*/
int ip_build_and_send_pkt(struct sk_buff *skb, const struct sock *sk,
__be32 saddr, __be32 daddr, struct ip_options_rcu *opt)
{
struct inet_sock *inet = inet_sk(sk);
struct rtable *rt = skb_rtable(skb);
struct net *net = sock_net(sk);
struct iphdr *iph;
/* Build the IP header. */
skb_push(skb, sizeof(struct iphdr) + (opt ? opt->opt.optlen : 0));
skb_reset_network_header(skb);
iph = ip_hdr(skb);
iph->version = 4;
iph->ihl = 5;
iph->tos = inet->tos;
iph->ttl = ip_select_ttl(inet, &rt->dst);
iph->daddr = (opt && opt->opt.srr ? opt->opt.faddr : daddr);
iph->saddr = saddr;
iph->protocol = sk->sk_protocol;
if (ip_dont_fragment(sk, &rt->dst)) {
iph->frag_off = htons(IP_DF);
iph->id = 0;
} else {
iph->frag_off = 0;
__ip_select_ident(net, iph, 1);
}
if (opt && opt->opt.optlen) {
iph->ihl += opt->opt.optlen>>2;
ip_options_build(skb, &opt->opt, daddr, rt, 0);
}
skb->priority = sk->sk_priority;
skb->mark = sk->sk_mark;
/* Send it out. */
return ip_local_out(net, skb->sk, skb);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 141 | 49.65% | 10 | 35.71% |
Eric Dumazet | 55 | 19.37% | 3 | 10.71% |
David S. Miller | 35 | 12.32% | 3 | 10.71% |
Arnaldo Carvalho de Melo | 17 | 5.99% | 4 | 14.29% |
Eric W. Biedermann | 17 | 5.99% | 3 | 10.71% |
Tóth László Attila | 8 | 2.82% | 1 | 3.57% |
Alexey Kuznetsov | 7 | 2.46% | 1 | 3.57% |
Al Viro | 2 | 0.70% | 1 | 3.57% |
Herbert Xu | 1 | 0.35% | 1 | 3.57% |
Hannes Frederic Sowa | 1 | 0.35% | 1 | 3.57% |
Total | 284 | 100.00% | 28 | 100.00% |
EXPORT_SYMBOL_GPL(ip_build_and_send_pkt);
static int ip_finish_output2(struct net *net, struct sock *sk, struct sk_buff *skb)
{
struct dst_entry *dst = skb_dst(skb);
struct rtable *rt = (struct rtable *)dst;
struct net_device *dev = dst->dev;
unsigned int hh_len = LL_RESERVED_SPACE(dev);
struct neighbour *neigh;
u32 nexthop;
if (rt->rt_type == RTN_MULTICAST) {
IP_UPD_PO_STATS(net, IPSTATS_MIB_OUTMCAST, skb->len);
} else if (rt->rt_type == RTN_BROADCAST)
IP_UPD_PO_STATS(net, IPSTATS_MIB_OUTBCAST, skb->len);
/* Be paranoid, rather than too clever. */
if (unlikely(skb_headroom(skb) < hh_len && dev->header_ops)) {
struct sk_buff *skb2;
skb2 = skb_realloc_headroom(skb, LL_RESERVED_SPACE(dev));
if (!skb2) {
kfree_skb(skb);
return -ENOMEM;
}
if (skb->sk)
skb_set_owner_w(skb2, skb->sk);
consume_skb(skb);
skb = skb2;
}
if (lwtunnel_xmit_redirect(dst->lwtstate)) {
int res = lwtunnel_xmit(skb);
if (res < 0 || res == LWTUNNEL_XMIT_DONE)
return res;
}
rcu_read_lock_bh();
nexthop = (__force u32) rt_nexthop(rt, ip_hdr(skb)->daddr);
neigh = __ipv4_neigh_lookup_noref(dev, nexthop);
if (unlikely(!neigh))
neigh = __neigh_create(&arp_tbl, &nexthop, dev, false);
if (!IS_ERR(neigh)) {
int res;
sock_confirm_neigh(skb, neigh);
res = neigh_output(neigh, skb);
rcu_read_unlock_bh();
return res;
}
rcu_read_unlock_bh();
net_dbg_ratelimited("%s: No header cache and no neighbour!\n",
__func__);
kfree_skb(skb);
return -EINVAL;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Alexey Kuznetsov | 89 | 27.38% | 2 | 7.14% |
David S. Miller | 62 | 19.08% | 6 | 21.43% |
Linus Torvalds (pre-git) | 37 | 11.38% | 3 | 10.71% |
Mitsuru Chinen | 35 | 10.77% | 1 | 3.57% |
Roopa Prabhu | 32 | 9.85% | 1 | 3.57% |
Julian Anastasov | 20 | 6.15% | 3 | 10.71% |
Eric Dumazet | 16 | 4.92% | 3 | 10.71% |
Neil Horman | 14 | 4.31% | 1 | 3.57% |
Eric W. Biedermann | 7 | 2.15% | 2 | 7.14% |
Vasiliy Kulikov | 4 | 1.23% | 1 | 3.57% |
Joe Perches | 4 | 1.23% | 1 | 3.57% |
Pavel Emelyanov | 2 | 0.62% | 1 | 3.57% |
Chuck Lever | 1 | 0.31% | 1 | 3.57% |
Ian Morris | 1 | 0.31% | 1 | 3.57% |
Stephen Hemminger | 1 | 0.31% | 1 | 3.57% |
Total | 325 | 100.00% | 28 | 100.00% |
static int ip_finish_output_gso(struct net *net, struct sock *sk,
struct sk_buff *skb, unsigned int mtu)
{
netdev_features_t features;
struct sk_buff *segs;
int ret = 0;
/* common case: seglen is <= mtu
*/
if (skb_gso_validate_mtu(skb, mtu))
return ip_finish_output2(net, sk, skb);
/* Slowpath - GSO segment length exceeds the egress MTU.
*
* This can happen in several cases:
* - Forwarding of a TCP GRO skb, when DF flag is not set.
* - Forwarding of an skb that arrived on a virtualization interface
* (virtio-net/vhost/tap) with TSO/GSO size set by other network
* stack.
* - Local GSO skb transmitted on an NETIF_F_TSO tunnel stacked over an
* interface with a smaller MTU.
* - Arriving GRO skb (or GSO skb in a virtualized environment) that is
* bridged to a NETIF_F_TSO tunnel stacked over an interface with an
* insufficent MTU.
*/
features = netif_skb_features(skb);
BUILD_BUG_ON(sizeof(*IPCB(skb)) > SKB_SGO_CB_OFFSET);
segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK);
if (IS_ERR_OR_NULL(segs)) {
kfree_skb(skb);
return -ENOMEM;
}
consume_skb(skb);
do {
struct sk_buff *nskb = segs->next;
int err;
segs->next = NULL;
err = ip_fragment(net, sk, segs, mtu, ip_finish_output2);
if (err && ret == 0)
ret = err;
segs = nskb;
} while (segs);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Westphal | 138 | 78.86% | 3 | 33.33% |
Konstantin Khlebnikov | 14 | 8.00% | 1 | 11.11% |
David S. Miller | 9 | 5.14% | 1 | 11.11% |
Eric W. Biedermann | 9 | 5.14% | 1 | 11.11% |
Marcelo Ricardo Leitner | 3 | 1.71% | 1 | 11.11% |
Lance Richardson | 2 | 1.14% | 2 | 22.22% |
Total | 175 | 100.00% | 9 | 100.00% |
static int ip_finish_output(struct net *net, struct sock *sk, struct sk_buff *skb)
{
unsigned int mtu;
int ret;
ret = BPF_CGROUP_RUN_PROG_INET_EGRESS(sk, skb);
if (ret) {
kfree_skb(skb);
return ret;
}
#if defined(CONFIG_NETFILTER) && defined(CONFIG_XFRM)
/* Policy lookup after SNAT yielded a new policy */
if (skb_dst(skb)->xfrm) {
IPCB(skb)->flags |= IPSKB_REROUTED;
return dst_output(net, sk, skb);
}
#endif
mtu = ip_skb_dst_mtu(sk, skb);
if (skb_is_gso(skb))
return ip_finish_output_gso(net, sk, skb, mtu);
if (skb->len > mtu || (IPCB(skb)->flags & IPSKB_FRAG_PMTU))
return ip_fragment(net, sk, skb, mtu, ip_finish_output2);
return ip_finish_output2(net, sk, skb);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 48 | 28.92% | 3 | 17.65% |
Florian Westphal | 40 | 24.10% | 3 | 17.65% |
Daniel Mack | 26 | 15.66% | 1 | 5.88% |
Linus Torvalds (pre-git) | 19 | 11.45% | 2 | 11.76% |
Eric W. Biedermann | 14 | 8.43% | 4 | 23.53% |
David S. Miller | 13 | 7.83% | 1 | 5.88% |
Eric Dumazet | 3 | 1.81% | 1 | 5.88% |
Shmulik Ladkani | 2 | 1.20% | 1 | 5.88% |
Adrian Bunk | 1 | 0.60% | 1 | 5.88% |
Total | 166 | 100.00% | 17 | 100.00% |
static int ip_mc_finish_output(struct net *net, struct sock *sk,
struct sk_buff *skb)
{
int ret;
ret = BPF_CGROUP_RUN_PROG_INET_EGRESS(sk, skb);
if (ret) {
kfree_skb(skb);
return ret;
}
return dev_loopback_xmit(net, sk, skb);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Daniel Mack | 57 | 100.00% | 1 | 100.00% |
Total | 57 | 100.00% | 1 | 100.00% |
int ip_mc_output(struct net *net, struct sock *sk, struct sk_buff *skb)
{
struct rtable *rt = skb_rtable(skb);
struct net_device *dev = rt->dst.dev;
/*
* If the indicated interface is up and running, send the packet.
*/
IP_UPD_PO_STATS(net, IPSTATS_MIB_OUT, skb->len);
skb->dev = dev;
skb->protocol = htons(ETH_P_IP);
/*
* Multicasts are looped back for other local users
*/
if (rt->rt_flags&RTCF_MULTICAST) {
if (sk_mc_loop(sk)
#ifdef CONFIG_IP_MROUTE
/* Small optimization: do not loopback not local frames,
which returned after forwarding; they will be dropped
by ip_mr_input in any case.
Note, that local frames are looped back to be delivered
to local recipients.
This check is duplicated in ip_mr_input at the moment.
*/
&&
((rt->rt_flags & RTCF_LOCAL) ||
!(IPCB(skb)->flags & IPSKB_FORWARDED))
#endif
) {
struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC);
if (newskb)
NF_HOOK(NFPROTO_IPV4, NF_INET_POST_ROUTING,
net, sk, newskb, NULL, newskb->dev,
ip_mc_finish_output);
}
/* Multicasts with ttl 0 must not go beyond the host */
if (ip_hdr(skb)->ttl == 0) {
kfree_skb(skb);
return 0;
}
}
if (rt->rt_flags&RTCF_BROADCAST) {
struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC);
if (newskb)
NF_HOOK(NFPROTO_IPV4, NF_INET_POST_ROUTING,
net, sk, newskb, NULL, newskb->dev,
ip_mc_finish_output);
}
return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING,
net, sk, skb, NULL, skb->dev,
ip_finish_output,
!(IPCB(skb)->flags & IPSKB_REROUTED));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 172 | 67.19% | 9 | 31.03% |
Patrick McHardy | 24 | 9.38% | 3 | 10.34% |
Eric W. Biedermann | 15 | 5.86% | 3 | 10.34% |
Eric Dumazet | 8 | 3.12% | 2 | 6.90% |
David S. Miller | 8 | 3.12% | 2 | 6.90% |
Linus Torvalds | 8 | 3.12% | 1 | 3.45% |
Neil Horman | 5 | 1.95% | 1 | 3.45% |
Alexey Kuznetsov | 4 | 1.56% | 1 | 3.45% |
Arnaldo Carvalho de Melo | 3 | 1.17% | 1 | 3.45% |
Jan Engelhardt | 3 | 1.17% | 1 | 3.45% |
Daniel Mack | 2 | 0.78% | 1 | 3.45% |
Pavel Emelyanov | 1 | 0.39% | 1 | 3.45% |
Herbert Xu | 1 | 0.39% | 1 | 3.45% |
Octavian Purdila | 1 | 0.39% | 1 | 3.45% |
Hideaki Yoshifuji / 吉藤英明 | 1 | 0.39% | 1 | 3.45% |
Total | 256 | 100.00% | 29 | 100.00% |
int ip_output(struct net *net, struct sock *sk, struct sk_buff *skb)
{
struct net_device *dev = skb_dst(skb)->dev;
IP_UPD_PO_STATS(net, IPSTATS_MIB_OUT, skb->len);
skb->dev = dev;
skb->protocol = htons(ETH_P_IP);
return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING,
net, sk, skb, NULL, dev,
ip_finish_output,
!(IPCB(skb)->flags & IPSKB_REROUTED));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 38 | 42.22% | 3 | 16.67% |
Linus Torvalds (pre-git) | 15 | 16.67% | 3 | 16.67% |
Eric W. Biedermann | 10 | 11.11% | 3 | 16.67% |
Eric Dumazet | 8 | 8.89% | 2 | 11.11% |
Alexey Kuznetsov | 7 | 7.78% | 1 | 5.56% |
Neil Horman | 5 | 5.56% | 1 | 5.56% |
David S. Miller | 2 | 2.22% | 1 | 5.56% |
Ananda Raju | 2 | 2.22% | 1 | 5.56% |
Herbert Xu | 1 | 1.11% | 1 | 5.56% |
Pavel Emelyanov | 1 | 1.11% | 1 | 5.56% |
Jan Engelhardt | 1 | 1.11% | 1 | 5.56% |
Total | 90 | 100.00% | 18 | 100.00% |
/*
* copy saddr and daddr, possibly using 64bit load/stores
* Equivalent to :
* iph->saddr = fl4->saddr;
* iph->daddr = fl4->daddr;
*/
static void ip_copy_addrs(struct iphdr *iph, const struct flowi4 *fl4)
{
BUILD_BUG_ON(offsetof(typeof(*fl4), daddr) !=
offsetof(typeof(*fl4), saddr) + sizeof(fl4->saddr));
memcpy(&iph->saddr, &fl4->saddr,
sizeof(fl4->saddr) + sizeof(fl4->daddr));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Eric Dumazet | 76 | 100.00% | 1 | 100.00% |
Total | 76 | 100.00% | 1 | 100.00% |
/* Note: skb->sk can be different from sk, in case of tunnels */
int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)
{
struct inet_sock *inet = inet_sk(sk);
struct net *net = sock_net(sk);
struct ip_options_rcu *inet_opt;
struct flowi4 *fl4;
struct rtable *rt;
struct iphdr *iph;
int res;
/* Skip all of this if the packet is already routed,
* f.e. by something like SCTP.
*/
rcu_read_lock();
inet_opt = rcu_dereference(inet->inet_opt);
fl4 = &fl->u.ip4;
rt = skb_rtable(skb);
if (rt)
goto packet_routed;
/* Make sure we can route this packet. */
rt = (struct rtable *)__sk_dst_check(sk, 0);
if (!rt) {
__be32 daddr;
/* Use correct destination address if we have options. */
daddr = inet->inet_daddr;
if (inet_opt && inet_opt->opt.srr)
daddr = inet_opt->opt.faddr;
/* If this fails, retransmit mechanism of transport layer will
* keep trying until route appears or the connection times
* itself out.
*/
rt = ip_route_output_ports(net, fl4, sk,
daddr, inet->inet_saddr,
inet->inet_dport,
inet->inet_sport,
sk->sk_protocol,
RT_CONN_FLAGS(sk),
sk->sk_bound_dev_if);
if (IS_ERR(rt))
goto no_route;
sk_setup_caps(sk, &rt->dst);
}
skb_dst_set_noref(skb, &rt->dst);
packet_routed:
if (inet_opt && inet_opt->opt.is_strictroute && rt->rt_uses_gateway)
goto no_route;
/* OK, we know where to send it, allocate and build IP header. */
skb_push(skb, sizeof(struct iphdr) + (inet_opt ? inet_opt->opt.optlen : 0));
skb_reset_network_header(skb);
iph = ip_hdr(skb);
*((__be16 *)iph) = htons((4 << 12) | (5 << 8) | (inet->tos & 0xff));
if (ip_dont_fragment(sk, &rt->dst) && !skb->ignore_df)
iph->frag_off = htons(IP_DF);
else
iph->frag_off = 0;
iph->ttl = ip_select_ttl(inet, &rt->dst);
iph->protocol = sk->sk_protocol;
ip_copy_addrs(iph, fl4);
/* Transport layer set skb->h.foo itself. */
if (inet_opt && inet_opt->opt.optlen) {
iph->ihl += inet_opt->opt.optlen >> 2;
ip_options_build(skb, &inet_opt->opt, inet->inet_daddr, rt, 0);
}
ip_select_ident_segs(net, skb, sk,
skb_shinfo(skb)->gso_segs ?: 1);
/* TODO : should we use skb->sk here instead of sk ? */
skb->priority = sk->sk_priority;
skb->mark = sk->sk_mark;
res = ip_local_out(net, sk, skb);
rcu_read_unlock();
return res;
no_route:
rcu_read_unlock();
IP_INC_STATS(net, IPSTATS_MIB_OUTNOROUTES);
kfree_skb(skb);
return -EHOSTUNREACH;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Alexey Kuznetsov | 212 | 43.80% | 3 | 5.45% |
Eric Dumazet | 73 | 15.08% | 8 | 14.55% |
Linus Torvalds (pre-git) | 71 | 14.67% | 5 | 9.09% |
David S. Miller | 61 | 12.60% | 10 | 18.18% |
Eric W. Biedermann | 18 | 3.72% | 4 | 7.27% |
Arnaldo Carvalho de Melo | 16 | 3.31% | 5 | 9.09% |
Tóth László Attila | 8 | 1.65% | 1 | 1.82% |
Herbert Xu | 4 | 0.83% | 2 | 3.64% |
Hideaki Yoshifuji / 吉藤英明 | 3 | 0.62% | 2 | 3.64% |
Shan Wei | 2 | 0.41% | 1 | 1.82% |
Denis V. Lunev | 2 | 0.41% | 2 | 3.64% |
Sridhar Samudrala | 2 | 0.41% | 1 | 1.82% |
Venkat Yekkirala | 2 | 0.41% | 1 | 1.82% |
Al Viro | 2 | 0.41% | 2 | 3.64% |
Ian Morris | 1 | 0.21% | 1 | 1.82% |
Américo Wang | 1 | 0.21% | 1 | 1.82% |
Ansis Atteka | 1 | 0.21% | 1 | 1.82% |
Linus Torvalds | 1 | 0.21% | 1 | 1.82% |
Atis Elsts | 1 | 0.21% | 1 | 1.82% |
Hannes Frederic Sowa | 1 | 0.21% | 1 | 1.82% |
Pavel Emelyanov | 1 | 0.21% | 1 | 1.82% |
Julian Anastasov | 1 | 0.21% | 1 | 1.82% |
Total | 484 | 100.00% | 55 | 100.00% |
EXPORT_SYMBOL(ip_queue_xmit);
static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from)
{
to->pkt_type = from->pkt_type;
to->priority = from->priority;
to->protocol = from->protocol;
skb_dst_drop(to);
skb_dst_copy(to, from);
to->dev = from->dev;
to->mark = from->mark;
/* Copy the flags to each fragment. */
IPCB(to)->flags = IPCB(from)->flags;
#ifdef CONFIG_NET_SCHED
to->tc_index = from->tc_index;
#endif
nf_copy(to, from);
#if IS_ENABLED(CONFIG_IP_VS)
to->ipvs_property = from->ipvs_property;
#endif
skb_copy_secmark(to, from);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Alexey Kuznetsov | 82 | 65.08% | 1 | 9.09% |
Julian Anastasov | 14 | 11.11% | 1 | 9.09% |
Thomas Graf | 8 | 6.35% | 1 | 9.09% |
James Morris | 7 | 5.56% | 1 | 9.09% |
Eric Dumazet | 5 | 3.97% | 2 | 18.18% |
Patrick McHardy | 4 | 3.17% | 1 | 9.09% |
Jozsef Kadlecsik | 3 | 2.38% | 2 | 18.18% |
Yasuyuki Kozakai | 2 | 1.59% | 1 | 9.09% |
Javier Martinez Canillas | 1 | 0.79% | 1 | 9.09% |
Total | 126 | 100.00% | 11 | 100.00% |
static int ip_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
unsigned int mtu,
int (*output)(struct net *, struct sock *, struct sk_buff *))
{
struct iphdr *iph = ip_hdr(skb);
if ((iph->frag_off & htons(IP_DF)) == 0)
return ip_do_fragment(net, sk, skb, output);
if (unlikely(!skb->ignore_df ||
(IPCB(skb)->frag_max_size &&
IPCB(skb)->frag_max_size > mtu))) {
IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS);
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
htonl(mtu));
kfree_skb(skb);
return -EMSGSIZE;
}
return ip_do_fragment(net, sk, skb, output);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Alexey Kuznetsov | 67 | 43.79% | 2 | 14.29% |
Florian Westphal | 21 | 13.73% | 2 | 14.29% |
Patrick McHardy | 18 | 11.76% | 1 | 7.14% |
Eric W. Biedermann | 14 | 9.15% | 2 | 14.29% |
Andy Zhou | 13 | 8.50% | 1 | 7.14% |
David S. Miller | 9 | 5.88% | 1 | 7.14% |
Wei Dong | 5 | 3.27% | 1 | 7.14% |
Eric Dumazet | 2 | 1.31% | 1 | 7.14% |
Hannes Frederic Sowa | 2 | 1.31% | 1 | 7.14% |
Pavel Emelyanov | 1 | 0.65% | 1 | 7.14% |
Américo Wang | 1 | 0.65% | 1 | 7.14% |
Total | 153 | 100.00% | 14 | 100.00% |
/*
* This IP datagram is too large to be sent in one piece. Break it up into
* smaller pieces (each of size equal to IP header plus
* a block of the data of the original IP data part) that will yet fit in a
* single device frame, and queue such a frame for sending.
*/
int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
int (*output)(struct net *, struct sock *, struct sk_buff *))
{
struct iphdr *iph;
int ptr;
struct sk_buff *skb2;
unsigned int mtu, hlen, left, len, ll_rs;
int offset;
__be16 not_last_frag;
struct rtable *rt = skb_rtable(skb);
int err = 0;
/* for offloaded checksums cleanup checksum before fragmentation */
if (skb->ip_summed == CHECKSUM_PARTIAL &&
(err = skb_checksum_help(skb)))
goto fail;
/*
* Point into the IP datagram header.
*/
iph = ip_hdr(skb);
mtu = ip_skb_dst_mtu(sk, skb);
if (IPCB(skb)->frag_max_size && IPCB(skb)->frag_max_size < mtu)
mtu = IPCB(skb)->frag_max_size;
/*
* Setup starting values.
*/
hlen = iph->ihl * 4;
mtu = mtu - hlen; /* Size of data space */
IPCB(skb)->flags |= IPSKB_FRAG_COMPLETE;
/* When frag_list is given, use it. First, check its validity:
* some transformers could create wrong frag_list or break existing
* one, it is not prohibited. In this case fall back to copying.
*
* LATER: this step can be merged to real generation of fragments,
* we can switch to copy when see the first bad fragment.
*/
if (skb_has_frag_list(skb)) {