~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/net/netfilter/nf_tables_ipv4.h

Version: ~ [ linux-5.11-rc3 ] ~ [ linux-5.10.7 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.89 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.167 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.215 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.251 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.251 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef _NF_TABLES_IPV4_H_
  3 #define _NF_TABLES_IPV4_H_
  4 
  5 #include <net/netfilter/nf_tables.h>
  6 #include <net/ip.h>
  7 
  8 static inline void nft_set_pktinfo_ipv4(struct nft_pktinfo *pkt,
  9                                         struct sk_buff *skb)
 10 {
 11         struct iphdr *ip;
 12 
 13         ip = ip_hdr(pkt->skb);
 14         pkt->tprot_set = true;
 15         pkt->tprot = ip->protocol;
 16         pkt->xt.thoff = ip_hdrlen(pkt->skb);
 17         pkt->xt.fragoff = ntohs(ip->frag_off) & IP_OFFSET;
 18 }
 19 
 20 static inline int __nft_set_pktinfo_ipv4_validate(struct nft_pktinfo *pkt,
 21                                                   struct sk_buff *skb)
 22 {
 23         struct iphdr *iph, _iph;
 24         u32 len, thoff;
 25 
 26         iph = skb_header_pointer(skb, skb_network_offset(skb), sizeof(*iph),
 27                                  &_iph);
 28         if (!iph)
 29                 return -1;
 30 
 31         if (iph->ihl < 5 || iph->version != 4)
 32                 return -1;
 33 
 34         len = ntohs(iph->tot_len);
 35         thoff = iph->ihl * 4;
 36         if (skb->len < len)
 37                 return -1;
 38         else if (len < thoff)
 39                 return -1;
 40 
 41         pkt->tprot_set = true;
 42         pkt->tprot = iph->protocol;
 43         pkt->xt.thoff = thoff;
 44         pkt->xt.fragoff = ntohs(iph->frag_off) & IP_OFFSET;
 45 
 46         return 0;
 47 }
 48 
 49 static inline void nft_set_pktinfo_ipv4_validate(struct nft_pktinfo *pkt,
 50                                                  struct sk_buff *skb)
 51 {
 52         if (__nft_set_pktinfo_ipv4_validate(pkt, skb) < 0)
 53                 nft_set_pktinfo_unspec(pkt, skb);
 54 }
 55 
 56 #endif
 57 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp