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

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

Version: ~ [ linux-5.19-rc3 ] ~ [ linux-5.18.5 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.48 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.123 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.199 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.248 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.284 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.319 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef _NF_TABLES_IPV6_H_
  3 #define _NF_TABLES_IPV6_H_
  4 
  5 #include <linux/netfilter_ipv6/ip6_tables.h>
  6 #include <net/ipv6.h>
  7 #include <net/netfilter/nf_tables.h>
  8 
  9 static inline void nft_set_pktinfo_ipv6(struct nft_pktinfo *pkt,
 10                                         struct sk_buff *skb)
 11 {
 12         unsigned int flags = IP6_FH_F_AUTH;
 13         int protohdr, thoff = 0;
 14         unsigned short frag_off;
 15 
 16         protohdr = ipv6_find_hdr(pkt->skb, &thoff, -1, &frag_off, &flags);
 17         if (protohdr < 0) {
 18                 nft_set_pktinfo_unspec(pkt, skb);
 19                 return;
 20         }
 21 
 22         pkt->tprot_set = true;
 23         pkt->tprot = protohdr;
 24         pkt->xt.thoff = thoff;
 25         pkt->xt.fragoff = frag_off;
 26 }
 27 
 28 static inline int __nft_set_pktinfo_ipv6_validate(struct nft_pktinfo *pkt,
 29                                                   struct sk_buff *skb)
 30 {
 31 #if IS_ENABLED(CONFIG_IPV6)
 32         unsigned int flags = IP6_FH_F_AUTH;
 33         struct ipv6hdr *ip6h, _ip6h;
 34         unsigned int thoff = 0;
 35         unsigned short frag_off;
 36         int protohdr;
 37         u32 pkt_len;
 38 
 39         ip6h = skb_header_pointer(skb, skb_network_offset(skb), sizeof(*ip6h),
 40                                   &_ip6h);
 41         if (!ip6h)
 42                 return -1;
 43 
 44         if (ip6h->version != 6)
 45                 return -1;
 46 
 47         pkt_len = ntohs(ip6h->payload_len);
 48         if (pkt_len + sizeof(*ip6h) > skb->len)
 49                 return -1;
 50 
 51         protohdr = ipv6_find_hdr(pkt->skb, &thoff, -1, &frag_off, &flags);
 52         if (protohdr < 0)
 53                 return -1;
 54 
 55         pkt->tprot_set = true;
 56         pkt->tprot = protohdr;
 57         pkt->xt.thoff = thoff;
 58         pkt->xt.fragoff = frag_off;
 59 
 60         return 0;
 61 #else
 62         return -1;
 63 #endif
 64 }
 65 
 66 static inline void nft_set_pktinfo_ipv6_validate(struct nft_pktinfo *pkt,
 67                                                  struct sk_buff *skb)
 68 {
 69         if (__nft_set_pktinfo_ipv6_validate(pkt, skb) < 0)
 70                 nft_set_pktinfo_unspec(pkt, skb);
 71 }
 72 
 73 #endif
 74 

~ [ 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