Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at ee9dce44362b2d8132c32964656ab6dff7dfbc6a 388 lines 9.0 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef _IPV6_H 3#define _IPV6_H 4 5#include <uapi/linux/ipv6.h> 6#include <linux/cache.h> 7 8#define ipv6_optlen(p) (((p)->hdrlen+1) << 3) 9#define ipv6_authlen(p) (((p)->hdrlen+2) << 2) 10/* 11 * This structure contains configuration options per IPv6 link. 12 */ 13struct ipv6_devconf { 14 /* RX & TX fastpath fields. */ 15 __cacheline_group_begin(ipv6_devconf_read_txrx); 16 __s32 disable_ipv6; 17 __s32 hop_limit; 18 __s32 mtu6; 19 __s32 forwarding; 20 __s32 force_forwarding; 21 __s32 disable_policy; 22 __s32 proxy_ndp; 23 __cacheline_group_end(ipv6_devconf_read_txrx); 24 25 __s32 accept_ra; 26 __s32 accept_redirects; 27 __s32 autoconf; 28 __s32 dad_transmits; 29 __s32 rtr_solicits; 30 __s32 rtr_solicit_interval; 31 __s32 rtr_solicit_max_interval; 32 __s32 rtr_solicit_delay; 33 __s32 force_mld_version; 34 __s32 mldv1_unsolicited_report_interval; 35 __s32 mldv2_unsolicited_report_interval; 36 __s32 use_tempaddr; 37 __s32 temp_valid_lft; 38 __s32 temp_prefered_lft; 39 __s32 regen_min_advance; 40 __s32 regen_max_retry; 41 __s32 max_desync_factor; 42 __s32 max_addresses; 43 __s32 accept_ra_defrtr; 44 __u32 ra_defrtr_metric; 45 __s32 accept_ra_min_hop_limit; 46 __s32 accept_ra_min_lft; 47 __s32 accept_ra_pinfo; 48 __s32 ignore_routes_with_linkdown; 49#ifdef CONFIG_IPV6_ROUTER_PREF 50 __s32 accept_ra_rtr_pref; 51 __s32 rtr_probe_interval; 52#ifdef CONFIG_IPV6_ROUTE_INFO 53 __s32 accept_ra_rt_info_min_plen; 54 __s32 accept_ra_rt_info_max_plen; 55#endif 56#endif 57 __s32 accept_source_route; 58 __s32 accept_ra_from_local; 59#ifdef CONFIG_IPV6_OPTIMISTIC_DAD 60 __s32 optimistic_dad; 61 __s32 use_optimistic; 62#endif 63#ifdef CONFIG_IPV6_MROUTE 64 atomic_t mc_forwarding; 65#endif 66 __s32 drop_unicast_in_l2_multicast; 67 __s32 accept_dad; 68 __s32 force_tllao; 69 __s32 ndisc_notify; 70 __s32 suppress_frag_ndisc; 71 __s32 accept_ra_mtu; 72 __s32 drop_unsolicited_na; 73 __s32 accept_untracked_na; 74 struct ipv6_stable_secret { 75 bool initialized; 76 struct in6_addr secret; 77 } stable_secret; 78 __s32 use_oif_addrs_only; 79 __s32 keep_addr_on_down; 80 __s32 seg6_enabled; 81#ifdef CONFIG_IPV6_SEG6_HMAC 82 __s32 seg6_require_hmac; 83#endif 84 __u32 enhanced_dad; 85 __u32 addr_gen_mode; 86 __s32 ndisc_tclass; 87 __s32 rpl_seg_enabled; 88 __u32 ioam6_id; 89 __u32 ioam6_id_wide; 90 __u8 ioam6_enabled; 91 __u8 ndisc_evict_nocarrier; 92 __u8 ra_honor_pio_life; 93 __u8 ra_honor_pio_pflag; 94 95 struct ctl_table_header *sysctl_header; 96}; 97 98struct ipv6_params { 99 __s32 disable_ipv6; 100 __s32 autoconf; 101}; 102extern struct ipv6_params ipv6_defaults; 103#include <linux/tcp.h> 104#include <linux/udp.h> 105 106#include <net/inet_sock.h> 107 108static inline struct ipv6hdr *ipv6_hdr(const struct sk_buff *skb) 109{ 110 return (struct ipv6hdr *)skb_network_header(skb); 111} 112 113static inline struct ipv6hdr *inner_ipv6_hdr(const struct sk_buff *skb) 114{ 115 return (struct ipv6hdr *)skb_inner_network_header(skb); 116} 117 118static inline struct ipv6hdr *ipipv6_hdr(const struct sk_buff *skb) 119{ 120 return (struct ipv6hdr *)skb_transport_header(skb); 121} 122 123static inline unsigned int ipv6_transport_len(const struct sk_buff *skb) 124{ 125 return ntohs(ipv6_hdr(skb)->payload_len) + sizeof(struct ipv6hdr) - 126 skb_network_header_len(skb); 127} 128 129static inline unsigned int 130ipv6_payload_len(const struct sk_buff *skb, const struct ipv6hdr *ip6) 131{ 132 u32 len = ntohs(ip6->payload_len); 133 134 return (len || !skb_is_gso(skb) || !skb_is_gso_tcp(skb)) ? 135 len : 136 skb->len - skb_network_offset(skb) - sizeof(struct ipv6hdr); 137} 138 139static inline unsigned int skb_ipv6_payload_len(const struct sk_buff *skb) 140{ 141 return ipv6_payload_len(skb, ipv6_hdr(skb)); 142} 143 144#define IPV6_MAXPLEN 65535 145 146static inline void ipv6_set_payload_len(struct ipv6hdr *ip6, unsigned int len) 147{ 148 ip6->payload_len = len <= IPV6_MAXPLEN ? htons(len) : 0; 149} 150 151/* 152 This structure contains results of exthdrs parsing 153 as offsets from skb->nh. 154 */ 155 156struct inet6_skb_parm { 157 int iif; 158 __be16 ra; 159 __u16 dst0; 160 __u16 srcrt; 161 __u16 dst1; 162 __u16 lastopt; 163 __u16 nhoff; 164 __u16 flags; 165#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) 166 __u16 dsthao; 167#endif 168 __u16 frag_max_size; 169 __u16 srhoff; 170 171#define IP6SKB_XFRM_TRANSFORMED 1 172#define IP6SKB_FORWARDED 2 173#define IP6SKB_REROUTED 4 174#define IP6SKB_ROUTERALERT 8 175#define IP6SKB_FRAGMENTED 16 176#define IP6SKB_HOPBYHOP 32 177#define IP6SKB_L3SLAVE 64 178#define IP6SKB_JUMBOGRAM 128 179#define IP6SKB_SEG6 256 180#define IP6SKB_MULTIPATH 1024 181#define IP6SKB_MCROUTE 2048 182}; 183 184#if defined(CONFIG_NET_L3_MASTER_DEV) 185static inline bool ipv6_l3mdev_skb(__u16 flags) 186{ 187 return flags & IP6SKB_L3SLAVE; 188} 189#else 190static inline bool ipv6_l3mdev_skb(__u16 flags) 191{ 192 return false; 193} 194#endif 195 196#define IP6CB(skb) ((struct inet6_skb_parm*)((skb)->cb)) 197#define IP6CBMTU(skb) ((struct ip6_mtuinfo *)((skb)->cb)) 198 199static inline int inet6_iif(const struct sk_buff *skb) 200{ 201 bool l3_slave = ipv6_l3mdev_skb(IP6CB(skb)->flags); 202 203 return l3_slave ? skb->skb_iif : IP6CB(skb)->iif; 204} 205 206static inline bool inet6_is_jumbogram(const struct sk_buff *skb) 207{ 208 return !!(IP6CB(skb)->flags & IP6SKB_JUMBOGRAM); 209} 210 211/* can not be used in TCP layer after tcp_v6_fill_cb */ 212static inline int inet6_sdif(const struct sk_buff *skb) 213{ 214#if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV) 215 if (skb && ipv6_l3mdev_skb(IP6CB(skb)->flags)) 216 return IP6CB(skb)->iif; 217#endif 218 return 0; 219} 220 221struct tcp6_request_sock { 222 struct tcp_request_sock tcp6rsk_tcp; 223}; 224 225struct ipv6_mc_socklist; 226struct ipv6_ac_socklist; 227struct ipv6_fl_socklist; 228 229/* struct ipv6_pinfo - ipv6 private area */ 230struct ipv6_pinfo { 231 /* Used in tx path (inet6_csk_route_socket(), ip6_xmit()) */ 232 struct in6_addr saddr; 233 union { 234 struct in6_addr daddr; 235 struct in6_addr final; 236 }; 237 __be32 flow_label; 238 u32 dst_cookie; 239 struct ipv6_txoptions __rcu *opt; 240 s16 hop_limit; 241 u8 pmtudisc; 242 u8 tclass; 243#ifdef CONFIG_IPV6_SUBTREES 244 bool saddr_cache; 245#endif 246 bool daddr_cache; 247 248 u8 mcast_hops; 249 u32 frag_size; 250 251 int ucast_oif; 252 int mcast_oif; 253 254 /* pktoption flags */ 255 union { 256 struct { 257 u16 srcrt:1, 258 osrcrt:1, 259 rxinfo:1, 260 rxoinfo:1, 261 rxhlim:1, 262 rxohlim:1, 263 hopopts:1, 264 ohopopts:1, 265 dstopts:1, 266 odstopts:1, 267 rxflow:1, 268 rxtclass:1, 269 rxpmtu:1, 270 rxorigdstaddr:1, 271 recvfragsize:1; 272 /* 1 bits hole */ 273 } bits; 274 u16 all; 275 } rxopt; 276 277 /* sockopt flags */ 278 u8 srcprefs; /* 001: prefer temporary address 279 * 010: prefer public address 280 * 100: prefer care-of address 281 */ 282 u8 min_hopcount; 283 __be32 rcv_flowinfo; 284 struct in6_pktinfo sticky_pktinfo; 285 286 struct sk_buff *pktoptions; 287 struct sk_buff *rxpmtu; 288 289 struct ipv6_mc_socklist __rcu *ipv6_mc_list; 290 struct ipv6_ac_socklist *ipv6_ac_list; 291}; 292 293/* We currently use available bits from inet_sk(sk)->inet_flags, 294 * this could change in the future. 295 */ 296#define inet6_test_bit(nr, sk) \ 297 test_bit(INET_FLAGS_##nr, &inet_sk(sk)->inet_flags) 298#define inet6_set_bit(nr, sk) \ 299 set_bit(INET_FLAGS_##nr, &inet_sk(sk)->inet_flags) 300#define inet6_clear_bit(nr, sk) \ 301 clear_bit(INET_FLAGS_##nr, &inet_sk(sk)->inet_flags) 302#define inet6_assign_bit(nr, sk, val) \ 303 assign_bit(INET_FLAGS_##nr, &inet_sk(sk)->inet_flags, val) 304 305/* WARNING: don't change the layout of the members in {raw,udp,tcp}6_sock! */ 306struct raw6_sock { 307 /* inet_sock has to be the first member of raw6_sock */ 308 struct inet_sock inet; 309 __u32 checksum; /* perform checksum */ 310 __u32 offset; /* checksum offset */ 311 struct icmp6_filter filter; 312 __u32 ip6mr_table; 313 struct numa_drop_counters drop_counters; 314 struct ipv6_pinfo inet6; 315}; 316 317struct udp6_sock { 318 struct udp_sock udp; 319 320 struct ipv6_pinfo inet6; 321}; 322 323struct tcp6_sock { 324 struct tcp_sock tcp; 325 326 struct ipv6_pinfo inet6; 327}; 328 329extern int inet6_sk_rebuild_header(struct sock *sk); 330 331struct tcp6_timewait_sock { 332 struct tcp_timewait_sock tcp6tw_tcp; 333}; 334 335#if IS_ENABLED(CONFIG_IPV6) 336extern int disable_ipv6_mod; 337 338static inline bool ipv6_mod_enabled(void) 339{ 340 return disable_ipv6_mod == 0; 341} 342 343static inline struct ipv6_pinfo *inet6_sk(const struct sock *__sk) 344{ 345 return sk_fullsock(__sk) ? inet_sk(__sk)->pinet6 : NULL; 346} 347 348#define raw6_sk(ptr) container_of_const(ptr, struct raw6_sock, inet.sk) 349 350#define ipv6_only_sock(sk) (sk->sk_ipv6only) 351#define ipv6_sk_rxinfo(sk) ((sk)->sk_family == PF_INET6 && \ 352 inet6_sk(sk)->rxopt.bits.rxinfo) 353 354static inline const struct in6_addr *inet6_rcv_saddr(const struct sock *sk) 355{ 356 if (sk->sk_family == AF_INET6) 357 return &sk->sk_v6_rcv_saddr; 358 return NULL; 359} 360 361static inline int inet_v6_ipv6only(const struct sock *sk) 362{ 363 /* ipv6only field is at same position for timewait and other sockets */ 364 return ipv6_only_sock(sk); 365} 366#else 367#define ipv6_only_sock(sk) 0 368#define ipv6_sk_rxinfo(sk) 0 369 370static inline bool ipv6_mod_enabled(void) 371{ 372 return false; 373} 374 375static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk) 376{ 377 return NULL; 378} 379 380static inline struct raw6_sock *raw6_sk(const struct sock *sk) 381{ 382 return NULL; 383} 384 385#define inet6_rcv_saddr(__sk) NULL 386#define inet_v6_ipv6only(__sk) 0 387#endif /* IS_ENABLED(CONFIG_IPV6) */ 388#endif /* _IPV6_H */