116 #define pr_fmt(fmt) "IPv4: " fmt
118 #include <linux/module.h>
119 #include <linux/types.h>
120 #include <linux/kernel.h>
121 #include <linux/string.h>
122 #include <linux/errno.h>
123 #include <linux/slab.h>
125 #include <linux/net.h>
126 #include <linux/socket.h>
128 #include <linux/in.h>
131 #include <linux/netdevice.h>
144 #include <linux/netfilter_ipv4.h>
146 #include <linux/mroute.h>
147 #include <linux/netlink.h>
165 if (sk && inet_sk(sk)->inet_num == protocol &&
166 (!sk->sk_bound_dev_if ||
167 sk->sk_bound_dev_if == dev->
ifindex) &&
168 net_eq(sock_net(sk), dev_net(dev))) {
169 if (ip_is_fragment(ip_hdr(skb))) {
189 static int ip_local_deliver_finish(
struct sk_buff *
skb)
193 __skb_pull(skb, ip_hdrlen(skb));
196 skb_reset_transport_header(skb);
200 int protocol = ip_hdr(skb)->protocol;
208 if (ipprot !=
NULL) {
258 if (ip_is_fragment(ip_hdr(skb))) {
264 ip_local_deliver_finish);
267 static inline bool ip_rcv_options(
struct sk_buff *skb)
270 const struct iphdr *iph;
280 if (skb_cow(skb, skb_headroom(skb))) {
286 opt = &(
IPCB(skb)->opt);
295 struct in_device *in_dev = __in_dev_get_rcu(dev);
298 if (!IN_DEV_SOURCE_ROUTE(in_dev)) {
299 if (IN_DEV_LOG_MARTIANS(in_dev))
319 static int ip_rcv_finish(
struct sk_buff *skb)
321 const struct iphdr *iph = ip_hdr(skb);
324 if (sysctl_ip_early_demux && !skb_dst(skb)) {
351 #ifdef CONFIG_IP_ROUTE_CLASSID
352 if (
unlikely(skb_dst(skb)->tclassid)) {
354 u32 idx = skb_dst(skb)->tclassid;
362 if (iph->ihl > 5 && ip_rcv_options(skb))
365 rt = skb_rtable(skb);
373 return dst_input(skb);
385 const struct iphdr *iph;
402 if (!pskb_may_pull(skb,
sizeof(
struct iphdr)))
418 if (iph->ihl < 5 || iph->version != 4)
421 if (!pskb_may_pull(skb, iph->ihl*4))
430 if (skb->
len < len) {
433 }
else if (len < (iph->ihl*4))
440 if (pskb_trim_rcsum(skb, len)) {