2017-11-01 22:09:13 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
|
2012-10-13 17:46:48 +08:00
|
|
|
/*
|
|
|
|
* INET An implementation of the TCP/IP protocol suite for the LINUX
|
|
|
|
* operating system. INET is implemented using the BSD Socket
|
|
|
|
* interface as the means of communication with the user level.
|
|
|
|
*
|
|
|
|
* Definitions for the IP protocol.
|
|
|
|
*
|
|
|
|
* Version: @(#)ip.h 1.0.2 04/28/93
|
|
|
|
*
|
|
|
|
* Authors: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
#ifndef _UAPI_LINUX_IP_H
|
|
|
|
#define _UAPI_LINUX_IP_H
|
|
|
|
#include <linux/types.h>
|
2023-02-04 00:04:48 +08:00
|
|
|
#include <linux/stddef.h>
|
2012-10-13 17:46:48 +08:00
|
|
|
#include <asm/byteorder.h>
|
|
|
|
|
|
|
|
#define IPTOS_TOS_MASK 0x1E
|
|
|
|
#define IPTOS_TOS(tos) ((tos)&IPTOS_TOS_MASK)
|
|
|
|
#define IPTOS_LOWDELAY 0x10
|
|
|
|
#define IPTOS_THROUGHPUT 0x08
|
|
|
|
#define IPTOS_RELIABILITY 0x04
|
|
|
|
#define IPTOS_MINCOST 0x02
|
|
|
|
|
|
|
|
#define IPTOS_PREC_MASK 0xE0
|
|
|
|
#define IPTOS_PREC(tos) ((tos)&IPTOS_PREC_MASK)
|
|
|
|
#define IPTOS_PREC_NETCONTROL 0xe0
|
|
|
|
#define IPTOS_PREC_INTERNETCONTROL 0xc0
|
|
|
|
#define IPTOS_PREC_CRITIC_ECP 0xa0
|
|
|
|
#define IPTOS_PREC_FLASHOVERRIDE 0x80
|
|
|
|
#define IPTOS_PREC_FLASH 0x60
|
|
|
|
#define IPTOS_PREC_IMMEDIATE 0x40
|
|
|
|
#define IPTOS_PREC_PRIORITY 0x20
|
|
|
|
#define IPTOS_PREC_ROUTINE 0x00
|
|
|
|
|
|
|
|
|
|
|
|
/* IP options */
|
|
|
|
#define IPOPT_COPY 0x80
|
|
|
|
#define IPOPT_CLASS_MASK 0x60
|
|
|
|
#define IPOPT_NUMBER_MASK 0x1f
|
|
|
|
|
|
|
|
#define IPOPT_COPIED(o) ((o)&IPOPT_COPY)
|
|
|
|
#define IPOPT_CLASS(o) ((o)&IPOPT_CLASS_MASK)
|
|
|
|
#define IPOPT_NUMBER(o) ((o)&IPOPT_NUMBER_MASK)
|
|
|
|
|
|
|
|
#define IPOPT_CONTROL 0x00
|
|
|
|
#define IPOPT_RESERVED1 0x20
|
|
|
|
#define IPOPT_MEASUREMENT 0x40
|
|
|
|
#define IPOPT_RESERVED2 0x60
|
|
|
|
|
|
|
|
#define IPOPT_END (0 |IPOPT_CONTROL)
|
|
|
|
#define IPOPT_NOOP (1 |IPOPT_CONTROL)
|
|
|
|
#define IPOPT_SEC (2 |IPOPT_CONTROL|IPOPT_COPY)
|
|
|
|
#define IPOPT_LSRR (3 |IPOPT_CONTROL|IPOPT_COPY)
|
|
|
|
#define IPOPT_TIMESTAMP (4 |IPOPT_MEASUREMENT)
|
|
|
|
#define IPOPT_CIPSO (6 |IPOPT_CONTROL|IPOPT_COPY)
|
|
|
|
#define IPOPT_RR (7 |IPOPT_CONTROL)
|
|
|
|
#define IPOPT_SID (8 |IPOPT_CONTROL|IPOPT_COPY)
|
|
|
|
#define IPOPT_SSRR (9 |IPOPT_CONTROL|IPOPT_COPY)
|
|
|
|
#define IPOPT_RA (20|IPOPT_CONTROL|IPOPT_COPY)
|
|
|
|
|
|
|
|
#define IPVERSION 4
|
|
|
|
#define MAXTTL 255
|
|
|
|
#define IPDEFTTL 64
|
|
|
|
|
|
|
|
#define IPOPT_OPTVAL 0
|
|
|
|
#define IPOPT_OLEN 1
|
|
|
|
#define IPOPT_OFFSET 2
|
|
|
|
#define IPOPT_MINOFF 4
|
|
|
|
#define MAX_IPOPTLEN 40
|
|
|
|
#define IPOPT_NOP IPOPT_NOOP
|
|
|
|
#define IPOPT_EOL IPOPT_END
|
|
|
|
#define IPOPT_TS IPOPT_TIMESTAMP
|
|
|
|
|
|
|
|
#define IPOPT_TS_TSONLY 0 /* timestamps only */
|
|
|
|
#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
|
|
|
|
#define IPOPT_TS_PRESPEC 3 /* specified modules only */
|
|
|
|
|
|
|
|
#define IPV4_BEET_PHMAXLEN 8
|
|
|
|
|
|
|
|
struct iphdr {
|
|
|
|
#if defined(__LITTLE_ENDIAN_BITFIELD)
|
|
|
|
__u8 ihl:4,
|
|
|
|
version:4;
|
|
|
|
#elif defined (__BIG_ENDIAN_BITFIELD)
|
|
|
|
__u8 version:4,
|
|
|
|
ihl:4;
|
|
|
|
#else
|
|
|
|
#error "Please fix <asm/byteorder.h>"
|
|
|
|
#endif
|
|
|
|
__u8 tos;
|
|
|
|
__be16 tot_len;
|
|
|
|
__be16 id;
|
|
|
|
__be16 frag_off;
|
|
|
|
__u8 ttl;
|
|
|
|
__u8 protocol;
|
|
|
|
__sum16 check;
|
2022-11-15 22:24:00 +08:00
|
|
|
__struct_group(/* no tag */, addrs, /* no attrs */,
|
|
|
|
__be32 saddr;
|
|
|
|
__be32 daddr;
|
|
|
|
);
|
2012-10-13 17:46:48 +08:00
|
|
|
/*The options start here. */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct ip_auth_hdr {
|
|
|
|
__u8 nexthdr;
|
|
|
|
__u8 hdrlen; /* This one is measured in 32 bit units! */
|
|
|
|
__be16 reserved;
|
|
|
|
__be32 spi;
|
|
|
|
__be32 seq_no; /* Sequence number */
|
2022-04-07 08:36:51 +08:00
|
|
|
__u8 auth_data[]; /* Variable len but >=4. Mind the 64 bit alignment! */
|
2012-10-13 17:46:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ip_esp_hdr {
|
|
|
|
__be32 spi;
|
|
|
|
__be32 seq_no; /* Sequence number */
|
2022-04-07 08:36:51 +08:00
|
|
|
__u8 enc_data[]; /* Variable len but >=8. Mind the 64 bit alignment! */
|
2012-10-13 17:46:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ip_comp_hdr {
|
|
|
|
__u8 nexthdr;
|
|
|
|
__u8 flags;
|
|
|
|
__be16 cpi;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ip_beet_phdr {
|
|
|
|
__u8 nexthdr;
|
|
|
|
__u8 hdrlen;
|
|
|
|
__u8 padlen;
|
|
|
|
__u8 reserved;
|
|
|
|
};
|
|
|
|
|
2013-08-22 12:09:47 +08:00
|
|
|
/* index values for the variables in ipv4_devconf */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
IPV4_DEVCONF_FORWARDING=1,
|
|
|
|
IPV4_DEVCONF_MC_FORWARDING,
|
|
|
|
IPV4_DEVCONF_PROXY_ARP,
|
|
|
|
IPV4_DEVCONF_ACCEPT_REDIRECTS,
|
|
|
|
IPV4_DEVCONF_SECURE_REDIRECTS,
|
|
|
|
IPV4_DEVCONF_SEND_REDIRECTS,
|
|
|
|
IPV4_DEVCONF_SHARED_MEDIA,
|
|
|
|
IPV4_DEVCONF_RP_FILTER,
|
|
|
|
IPV4_DEVCONF_ACCEPT_SOURCE_ROUTE,
|
|
|
|
IPV4_DEVCONF_BOOTP_RELAY,
|
|
|
|
IPV4_DEVCONF_LOG_MARTIANS,
|
|
|
|
IPV4_DEVCONF_TAG,
|
|
|
|
IPV4_DEVCONF_ARPFILTER,
|
|
|
|
IPV4_DEVCONF_MEDIUM_ID,
|
|
|
|
IPV4_DEVCONF_NOXFRM,
|
|
|
|
IPV4_DEVCONF_NOPOLICY,
|
|
|
|
IPV4_DEVCONF_FORCE_IGMP_VERSION,
|
|
|
|
IPV4_DEVCONF_ARP_ANNOUNCE,
|
|
|
|
IPV4_DEVCONF_ARP_IGNORE,
|
|
|
|
IPV4_DEVCONF_PROMOTE_SECONDARIES,
|
|
|
|
IPV4_DEVCONF_ARP_ACCEPT,
|
|
|
|
IPV4_DEVCONF_ARP_NOTIFY,
|
|
|
|
IPV4_DEVCONF_ACCEPT_LOCAL,
|
|
|
|
IPV4_DEVCONF_SRC_VMARK,
|
|
|
|
IPV4_DEVCONF_PROXY_ARP_PVLAN,
|
|
|
|
IPV4_DEVCONF_ROUTE_LOCALNET,
|
2013-08-27 04:37:08 +08:00
|
|
|
IPV4_DEVCONF_IGMPV2_UNSOLICITED_REPORT_INTERVAL,
|
|
|
|
IPV4_DEVCONF_IGMPV3_UNSOLICITED_REPORT_INTERVAL,
|
2015-06-24 01:45:37 +08:00
|
|
|
IPV4_DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN,
|
2016-02-04 20:31:17 +08:00
|
|
|
IPV4_DEVCONF_DROP_UNICAST_IN_L2_MULTICAST,
|
2016-02-04 20:31:18 +08:00
|
|
|
IPV4_DEVCONF_DROP_GRATUITOUS_ARP,
|
2018-07-27 16:37:28 +08:00
|
|
|
IPV4_DEVCONF_BC_FORWARDING,
|
net: arp: introduce arp_evict_nocarrier sysctl parameter
This change introduces a new sysctl parameter, arp_evict_nocarrier.
When set (default) the ARP cache will be cleared on a NOCARRIER event.
This new option has been defaulted to '1' which maintains existing
behavior.
Clearing the ARP cache on NOCARRIER is relatively new, introduced by:
commit 859bd2ef1fc1110a8031b967ee656c53a6260a76
Author: David Ahern <dsahern@gmail.com>
Date: Thu Oct 11 20:33:49 2018 -0700
net: Evict neighbor entries on carrier down
The reason for this changes is to prevent the ARP cache from being
cleared when a wireless device roams. Specifically for wireless roams
the ARP cache should not be cleared because the underlying network has not
changed. Clearing the ARP cache in this case can introduce significant
delays sending out packets after a roam.
A user reported such a situation here:
https://lore.kernel.org/linux-wireless/CACsRnHWa47zpx3D1oDq9JYnZWniS8yBwW1h0WAVZ6vrbwL_S0w@mail.gmail.com/
After some investigation it was found that the kernel was holding onto
packets until ARP finished which resulted in this 1 second delay. It
was also found that the first ARP who-has was never responded to,
which is actually what caues the delay. This change is more or less
working around this behavior, but again, there is no reason to clear
the cache on a roam anyways.
As for the unanswered who-has, we know the packet made it OTA since
it was seen while monitoring. Why it never received a response is
unknown. In any case, since this is a problem on the AP side of things
all that can be done is to work around it until it is solved.
Some background on testing/reproducing the packet delay:
Hardware:
- 2 access points configured for Fast BSS Transition (Though I don't
see why regular reassociation wouldn't have the same behavior)
- Wireless station running IWD as supplicant
- A device on network able to respond to pings (I used one of the APs)
Procedure:
- Connect to first AP
- Ping once to establish an ARP entry
- Start a tcpdump
- Roam to second AP
- Wait for operstate UP event, and note the timestamp
- Start pinging
Results:
Below is the tcpdump after UP. It was recorded the interface went UP at
10:42:01.432875.
10:42:01.461871 ARP, Request who-has 192.168.254.1 tell 192.168.254.71, length 28
10:42:02.497976 ARP, Request who-has 192.168.254.1 tell 192.168.254.71, length 28
10:42:02.507162 ARP, Reply 192.168.254.1 is-at ac:86:74:55:b0:20, length 46
10:42:02.507185 IP 192.168.254.71 > 192.168.254.1: ICMP echo request, id 52792, seq 1, length 64
10:42:02.507205 IP 192.168.254.71 > 192.168.254.1: ICMP echo request, id 52792, seq 2, length 64
10:42:02.507212 IP 192.168.254.71 > 192.168.254.1: ICMP echo request, id 52792, seq 3, length 64
10:42:02.507219 IP 192.168.254.71 > 192.168.254.1: ICMP echo request, id 52792, seq 4, length 64
10:42:02.507225 IP 192.168.254.71 > 192.168.254.1: ICMP echo request, id 52792, seq 5, length 64
10:42:02.507232 IP 192.168.254.71 > 192.168.254.1: ICMP echo request, id 52792, seq 6, length 64
10:42:02.515373 IP 192.168.254.1 > 192.168.254.71: ICMP echo reply, id 52792, seq 1, length 64
10:42:02.521399 IP 192.168.254.1 > 192.168.254.71: ICMP echo reply, id 52792, seq 2, length 64
10:42:02.521612 IP 192.168.254.1 > 192.168.254.71: ICMP echo reply, id 52792, seq 3, length 64
10:42:02.521941 IP 192.168.254.1 > 192.168.254.71: ICMP echo reply, id 52792, seq 4, length 64
10:42:02.522419 IP 192.168.254.1 > 192.168.254.71: ICMP echo reply, id 52792, seq 5, length 64
10:42:02.523085 IP 192.168.254.1 > 192.168.254.71: ICMP echo reply, id 52792, seq 6, length 64
You can see the first ARP who-has went out very quickly after UP, but
was never responded to. Nearly a second later the kernel retries and
gets a response. Only then do the ping packets go out. If an ARP entry
is manually added prior to UP (after the cache is cleared) it is seen
that the first ping is never responded to, so its not only an issue with
ARP but with data packets in general.
As mentioned prior, the wireless interface was also monitored to verify
the ping/ARP packet made it OTA which was observed to be true.
Signed-off-by: James Prestwood <prestwoj@gmail.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-11-02 01:36:28 +08:00
|
|
|
IPV4_DEVCONF_ARP_EVICT_NOCARRIER,
|
2013-08-22 12:09:47 +08:00
|
|
|
__IPV4_DEVCONF_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
#define IPV4_DEVCONF_MAX (__IPV4_DEVCONF_MAX - 1)
|
|
|
|
|
2012-10-13 17:46:48 +08:00
|
|
|
#endif /* _UAPI_LINUX_IP_H */
|