2017-11-01 22:08:43 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
2012-10-13 17:46:48 +08:00
|
|
|
#ifndef _UAPI_IPV6_H
|
|
|
|
#define _UAPI_IPV6_H
|
|
|
|
|
2015-01-13 03:29:34 +08:00
|
|
|
#include <linux/libc-compat.h>
|
2012-10-13 17:46:48 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/in6.h>
|
|
|
|
#include <asm/byteorder.h>
|
|
|
|
|
|
|
|
/* The latest drafts declared increase in minimal mtu up to 1280. */
|
|
|
|
|
|
|
|
#define IPV6_MIN_MTU 1280
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Advanced API
|
|
|
|
* source interface/address selection, source routing, etc...
|
|
|
|
* *under construction*
|
|
|
|
*/
|
|
|
|
|
2015-01-07 07:45:31 +08:00
|
|
|
#if __UAPI_DEF_IN6_PKTINFO
|
2012-10-13 17:46:48 +08:00
|
|
|
struct in6_pktinfo {
|
|
|
|
struct in6_addr ipi6_addr;
|
|
|
|
int ipi6_ifindex;
|
|
|
|
};
|
2015-01-07 07:45:31 +08:00
|
|
|
#endif
|
2012-10-13 17:46:48 +08:00
|
|
|
|
2015-01-07 07:45:31 +08:00
|
|
|
#if __UAPI_DEF_IP6_MTUINFO
|
2012-10-13 17:46:48 +08:00
|
|
|
struct ip6_mtuinfo {
|
|
|
|
struct sockaddr_in6 ip6m_addr;
|
|
|
|
__u32 ip6m_mtu;
|
|
|
|
};
|
2015-01-07 07:45:31 +08:00
|
|
|
#endif
|
2012-10-13 17:46:48 +08:00
|
|
|
|
|
|
|
struct in6_ifreq {
|
|
|
|
struct in6_addr ifr6_addr;
|
|
|
|
__u32 ifr6_prefixlen;
|
|
|
|
int ifr6_ifindex;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define IPV6_SRCRT_STRICT 0x01 /* Deprecated; will be removed */
|
|
|
|
#define IPV6_SRCRT_TYPE_0 0 /* Deprecated; will be removed */
|
|
|
|
#define IPV6_SRCRT_TYPE_2 2 /* IPv6 type 2 Routing Header */
|
2016-11-08 21:57:39 +08:00
|
|
|
#define IPV6_SRCRT_TYPE_4 4 /* Segment Routing with IPv6 */
|
2012-10-13 17:46:48 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* routing header
|
|
|
|
*/
|
|
|
|
struct ipv6_rt_hdr {
|
|
|
|
__u8 nexthdr;
|
|
|
|
__u8 hdrlen;
|
|
|
|
__u8 type;
|
|
|
|
__u8 segments_left;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* type specific data
|
|
|
|
* variable length field
|
|
|
|
*/
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct ipv6_opt_hdr {
|
|
|
|
__u8 nexthdr;
|
|
|
|
__u8 hdrlen;
|
|
|
|
/*
|
|
|
|
* TLV encoded option data follows.
|
|
|
|
*/
|
|
|
|
} __attribute__((packed)); /* required for some archs */
|
|
|
|
|
|
|
|
#define ipv6_destopt_hdr ipv6_opt_hdr
|
|
|
|
#define ipv6_hopopt_hdr ipv6_opt_hdr
|
|
|
|
|
2013-01-13 13:02:45 +08:00
|
|
|
/* Router Alert option values (RFC2711) */
|
|
|
|
#define IPV6_OPT_ROUTERALERT_MLD 0x0000 /* MLD(RFC2710) */
|
2012-10-13 17:46:48 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* routing header type 0 (used in cmsghdr struct)
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct rt0_hdr {
|
|
|
|
struct ipv6_rt_hdr rt_hdr;
|
|
|
|
__u32 reserved;
|
|
|
|
struct in6_addr addr[0];
|
|
|
|
|
|
|
|
#define rt0_type rt_hdr.type
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* routing header type 2
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct rt2_hdr {
|
|
|
|
struct ipv6_rt_hdr rt_hdr;
|
|
|
|
__u32 reserved;
|
|
|
|
struct in6_addr addr;
|
|
|
|
|
|
|
|
#define rt2_type rt_hdr.type
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* home address option in destination options header
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct ipv6_destopt_hao {
|
|
|
|
__u8 type;
|
|
|
|
__u8 length;
|
|
|
|
struct in6_addr addr;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IPv6 fixed header
|
|
|
|
*
|
|
|
|
* BEWARE, it is incorrect. The first 4 bits of flow_lbl
|
|
|
|
* are glued to priority now, forming "class".
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct ipv6hdr {
|
|
|
|
#if defined(__LITTLE_ENDIAN_BITFIELD)
|
|
|
|
__u8 priority:4,
|
|
|
|
version:4;
|
|
|
|
#elif defined(__BIG_ENDIAN_BITFIELD)
|
|
|
|
__u8 version:4,
|
|
|
|
priority:4;
|
|
|
|
#else
|
|
|
|
#error "Please fix <asm/byteorder.h>"
|
|
|
|
#endif
|
|
|
|
__u8 flow_lbl[3];
|
|
|
|
|
|
|
|
__be16 payload_len;
|
|
|
|
__u8 nexthdr;
|
|
|
|
__u8 hop_limit;
|
|
|
|
|
|
|
|
struct in6_addr saddr;
|
|
|
|
struct in6_addr daddr;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* index values for the variables in ipv6_devconf */
|
|
|
|
enum {
|
|
|
|
DEVCONF_FORWARDING = 0,
|
|
|
|
DEVCONF_HOPLIMIT,
|
|
|
|
DEVCONF_MTU6,
|
|
|
|
DEVCONF_ACCEPT_RA,
|
|
|
|
DEVCONF_ACCEPT_REDIRECTS,
|
|
|
|
DEVCONF_AUTOCONF,
|
|
|
|
DEVCONF_DAD_TRANSMITS,
|
|
|
|
DEVCONF_RTR_SOLICITS,
|
|
|
|
DEVCONF_RTR_SOLICIT_INTERVAL,
|
|
|
|
DEVCONF_RTR_SOLICIT_DELAY,
|
|
|
|
DEVCONF_USE_TEMPADDR,
|
|
|
|
DEVCONF_TEMP_VALID_LFT,
|
|
|
|
DEVCONF_TEMP_PREFERED_LFT,
|
|
|
|
DEVCONF_REGEN_MAX_RETRY,
|
|
|
|
DEVCONF_MAX_DESYNC_FACTOR,
|
|
|
|
DEVCONF_MAX_ADDRESSES,
|
|
|
|
DEVCONF_FORCE_MLD_VERSION,
|
|
|
|
DEVCONF_ACCEPT_RA_DEFRTR,
|
|
|
|
DEVCONF_ACCEPT_RA_PINFO,
|
|
|
|
DEVCONF_ACCEPT_RA_RTR_PREF,
|
|
|
|
DEVCONF_RTR_PROBE_INTERVAL,
|
|
|
|
DEVCONF_ACCEPT_RA_RT_INFO_MAX_PLEN,
|
|
|
|
DEVCONF_PROXY_NDP,
|
|
|
|
DEVCONF_OPTIMISTIC_DAD,
|
|
|
|
DEVCONF_ACCEPT_SOURCE_ROUTE,
|
|
|
|
DEVCONF_MC_FORWARDING,
|
|
|
|
DEVCONF_DISABLE_IPV6,
|
|
|
|
DEVCONF_ACCEPT_DAD,
|
|
|
|
DEVCONF_FORCE_TLLAO,
|
2012-11-07 00:46:20 +08:00
|
|
|
DEVCONF_NDISC_NOTIFY,
|
2013-08-14 07:03:46 +08:00
|
|
|
DEVCONF_MLDV1_UNSOLICITED_REPORT_INTERVAL,
|
|
|
|
DEVCONF_MLDV2_UNSOLICITED_REPORT_INTERVAL,
|
2013-08-27 07:36:51 +08:00
|
|
|
DEVCONF_SUPPRESS_FRAG_NDISC,
|
2014-06-26 05:44:53 +08:00
|
|
|
DEVCONF_ACCEPT_RA_FROM_LOCAL,
|
net: ipv6: Add a sysctl to make optimistic addresses useful candidates
Add a sysctl that causes an interface's optimistic addresses
to be considered equivalent to other non-deprecated addresses
for source address selection purposes. Preferred addresses
will still take precedence over optimistic addresses, subject
to other ranking in the source address selection algorithm.
This is useful where different interfaces are connected to
different networks from different ISPs (e.g., a cell network
and a home wifi network).
The current behaviour complies with RFC 3484/6724, and it
makes sense if the host has only one interface, or has
multiple interfaces on the same network (same or cooperating
administrative domain(s), but not in the multiple distinct
networks case.
For example, if a mobile device has an IPv6 address on an LTE
network and then connects to IPv6-enabled wifi, while the wifi
IPv6 address is undergoing DAD, IPv6 connections will try use
the wifi default route with the LTE IPv6 address, and will get
stuck until they time out.
Also, because optimistic nodes can receive frames, issue
an RTM_NEWADDR as soon as DAD starts (with the IFA_F_OPTIMSTIC
flag appropriately set). A second RTM_NEWADDR is sent if DAD
completes (the address flags have changed), otherwise an
RTM_DELADDR is sent.
Also: add an entry in ip-sysctl.txt for optimistic_dad.
Signed-off-by: Erik Kline <ek@google.com>
Acked-by: Lorenzo Colitti <lorenzo@google.com>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-10-28 17:11:14 +08:00
|
|
|
DEVCONF_USE_OPTIMISTIC,
|
2015-01-21 01:06:05 +08:00
|
|
|
DEVCONF_ACCEPT_RA_MTU,
|
2015-03-24 06:36:00 +08:00
|
|
|
DEVCONF_STABLE_SECRET,
|
2015-07-22 15:38:25 +08:00
|
|
|
DEVCONF_USE_OIF_ADDRS_ONLY,
|
2015-07-30 14:28:42 +08:00
|
|
|
DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT,
|
2015-08-13 22:39:01 +08:00
|
|
|
DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN,
|
2016-02-04 20:31:19 +08:00
|
|
|
DEVCONF_DROP_UNICAST_IN_L2_MULTICAST,
|
2016-02-04 20:31:20 +08:00
|
|
|
DEVCONF_DROP_UNSOLICITED_NA,
|
net: ipv6: Make address flushing on ifdown optional
Currently, all ipv6 addresses are flushed when the interface is configured
down, including global, static addresses:
$ ip -6 addr show dev eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000
inet6 2100:1::2/120 scope global
valid_lft forever preferred_lft forever
inet6 fe80::e0:f9ff:fe79:34bd/64 scope link
valid_lft forever preferred_lft forever
$ ip link set dev eth1 down
$ ip -6 addr show dev eth1
<< nothing; all addresses have been flushed>>
Add a new sysctl to make this behavior optional. The new setting defaults to
flush all addresses to maintain backwards compatibility. When the set global
addresses with no expire times are not flushed on an admin down. The sysctl
is per-interface or system-wide for all interfaces
$ sysctl -w net.ipv6.conf.eth1.keep_addr_on_down=1
or
$ sysctl -w net.ipv6.conf.all.keep_addr_on_down=1
Will keep addresses on eth1 on an admin down.
$ ip -6 addr show dev eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000
inet6 2100:1::2/120 scope global
valid_lft forever preferred_lft forever
inet6 fe80::e0:f9ff:fe79:34bd/64 scope link
valid_lft forever preferred_lft forever
$ ip link set dev eth1 down
$ ip -6 addr show dev eth1
3: eth1: <BROADCAST,MULTICAST> mtu 1500 state DOWN qlen 1000
inet6 2100:1::2/120 scope global tentative
valid_lft forever preferred_lft forever
inet6 fe80::e0:f9ff:fe79:34bd/64 scope link tentative
valid_lft forever preferred_lft forever
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-02-25 01:25:37 +08:00
|
|
|
DEVCONF_KEEP_ADDR_ON_DOWN,
|
2016-09-28 14:57:58 +08:00
|
|
|
DEVCONF_RTR_SOLICIT_MAX_INTERVAL,
|
2016-11-08 21:57:39 +08:00
|
|
|
DEVCONF_SEG6_ENABLED,
|
2016-11-08 21:57:42 +08:00
|
|
|
DEVCONF_SEG6_REQUIRE_HMAC,
|
2016-12-03 06:00:08 +08:00
|
|
|
DEVCONF_ENHANCED_DAD,
|
2017-01-26 11:59:17 +08:00
|
|
|
DEVCONF_ADDR_GEN_MODE,
|
2017-02-24 00:27:18 +08:00
|
|
|
DEVCONF_DISABLE_POLICY,
|
2017-03-22 17:19:04 +08:00
|
|
|
DEVCONF_ACCEPT_RA_RT_INFO_MIN_PLEN,
|
net: ipv6: sysctl to specify IPv6 ND traffic class
Add a per-device sysctl to specify the default traffic class to use for
kernel originated IPv6 Neighbour Discovery packets.
Currently this includes:
- Router Solicitation (ICMPv6 type 133)
ndisc_send_rs() -> ndisc_send_skb() -> ip6_nd_hdr()
- Neighbour Solicitation (ICMPv6 type 135)
ndisc_send_ns() -> ndisc_send_skb() -> ip6_nd_hdr()
- Neighbour Advertisement (ICMPv6 type 136)
ndisc_send_na() -> ndisc_send_skb() -> ip6_nd_hdr()
- Redirect (ICMPv6 type 137)
ndisc_send_redirect() -> ndisc_send_skb() -> ip6_nd_hdr()
and if the kernel ever gets around to generating RA's,
it would presumably also include:
- Router Advertisement (ICMPv6 type 134)
(radvd daemon could pick up on the kernel setting and use it)
Interface drivers may examine the Traffic Class value and translate
the DiffServ Code Point into a link-layer appropriate traffic
prioritization scheme. An example of mapping IETF DSCP values to
IEEE 802.11 User Priority values can be found here:
https://tools.ietf.org/html/draft-ietf-tsvwg-ieee-802-11
The expected primary use case is to properly prioritize ND over wifi.
Testing:
jzem22:~# cat /proc/sys/net/ipv6/conf/eth0/ndisc_tclass
0
jzem22:~# echo -1 > /proc/sys/net/ipv6/conf/eth0/ndisc_tclass
-bash: echo: write error: Invalid argument
jzem22:~# echo 256 > /proc/sys/net/ipv6/conf/eth0/ndisc_tclass
-bash: echo: write error: Invalid argument
jzem22:~# echo 0 > /proc/sys/net/ipv6/conf/eth0/ndisc_tclass
jzem22:~# echo 255 > /proc/sys/net/ipv6/conf/eth0/ndisc_tclass
jzem22:~# cat /proc/sys/net/ipv6/conf/eth0/ndisc_tclass
255
jzem22:~# echo 34 > /proc/sys/net/ipv6/conf/eth0/ndisc_tclass
jzem22:~# cat /proc/sys/net/ipv6/conf/eth0/ndisc_tclass
34
jzem22:~# echo $[0xDC] > /proc/sys/net/ipv6/conf/eth0/ndisc_tclass
jzem22:~# tcpdump -v -i eth0 icmp6 and src host jzem22.pgc and dst host fe80::1
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
IP6 (class 0xdc, hlim 255, next-header ICMPv6 (58) payload length: 24)
jzem22.pgc > fe80::1: [icmp6 sum ok] ICMP6, neighbor advertisement,
length 24, tgt is jzem22.pgc, Flags [solicited]
(based on original change written by Erik Kline, with minor changes)
v2: fix 'suspicious rcu_dereference_check() usage'
by explicitly grabbing the rcu_read_lock.
Cc: Lorenzo Colitti <lorenzo@google.com>
Signed-off-by: Erik Kline <ek@google.com>
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-11-08 13:52:09 +08:00
|
|
|
DEVCONF_NDISC_TCLASS,
|
2012-10-13 17:46:48 +08:00
|
|
|
DEVCONF_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* _UAPI_IPV6_H */
|