Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
53cfa73
net: ip: pmtu: Add generic IP PMTU Discovery support
jukkar Nov 1, 2024
0ca36f7
tests: net: pmtu: Add tests for path MTU discovery
jukkar Nov 1, 2024
6c52634
net: stats: ipv6: pmtu: Add Path MTU Discovery statistics
jukkar Nov 1, 2024
b4df05c
net: ipv6: Print verdict information
jukkar Nov 5, 2024
9476662
net: ipv6: Add PMTU support
jukkar Nov 5, 2024
7ebc1a7
tests: net: pmtu: Add IPv6 specific PMTU TCP tests
jukkar Nov 5, 2024
6364a2d
net: shell: Add pmtu command to the net-shell
jukkar Nov 5, 2024
a52c866
net: stats: ipv4: pmtu: Add Path MTU Discovery statistics
jukkar Nov 5, 2024
7c3cf50
net: ipv4: Add PMTU support
jukkar Nov 5, 2024
09aae0d
tests: net: pmtu: Add IPv4 specific PMTU TCP tests
jukkar Nov 5, 2024
1c93c7e
net: pmtu: Send net_mgmt event for changed path MTU
jukkar Nov 6, 2024
c5ed863
tests: net: pmtu: Add network event tests for pmtu
jukkar Nov 6, 2024
722595d
net: shell: events: Print PMTU event values
jukkar Nov 6, 2024
b0145a7
net: shell: events: Set the command mask correctly
jukkar Nov 6, 2024
ad693c9
net: Add support for IP_MTU IPv4 socket option
jukkar Nov 12, 2024
fa8e489
tests: net: pmtu: Add IP_MTU socket option tests
jukkar Nov 12, 2024
ca6decb
net: Add support for IPV6_MTU IPv6 socket option
jukkar Nov 13, 2024
a77e506
tests: net: pmtu: Add IPV6_MTU socket option tests
jukkar Nov 13, 2024
b067a2a
net: ipv4_fragment: Add PMTU support
jukkar Nov 13, 2024
b9c2e7a
tests: net: ipv4_fragment: Add PMTU testing
jukkar Nov 13, 2024
df788c0
tests: net: ipv4_fragment: Make test to run faster
jukkar Nov 13, 2024
6177285
net: ipv6_fragment: Add PMTU support
jukkar Nov 13, 2024
8d61425
tests: net: ipv6_fragment: Add PMTU testing
jukkar Nov 13, 2024
32e3339
net: ipv6_fragment: Data in one frag must be multiple of 8
jukkar Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/zephyr/net/net_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,8 @@
NET_OPT_TTL = 16, /**< IPv4 unicast TTL */
NET_OPT_ADDR_PREFERENCES = 17, /**< IPv6 address preference */
NET_OPT_TIMESTAMPING = 18, /**< Packet timestamping */
NET_OPT_MTU = 20, /**< IPv4 socket path MTU */
};

Check notice on line 1296 in include/zephyr/net/net_context.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

include/zephyr/net/net_context.h:1296 - NET_OPT_MTU = 20, /**< IPv4 socket path MTU */ + NET_OPT_MTU = 20, /**< IPv4 socket path MTU */

/**
* @brief Set an connection option for this context.
Expand Down
38 changes: 38 additions & 0 deletions include/zephyr/net/net_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
NET_EVENT_IPV6_CMD_PE_DISABLED,
NET_EVENT_IPV6_CMD_PE_FILTER_ADD,
NET_EVENT_IPV6_CMD_PE_FILTER_DEL,
NET_EVENT_IPV6_CMD_PMTU_CHANGED,
};

/* IPv4 Events*/
Expand All @@ -99,6 +100,7 @@
NET_EVENT_IPV4_CMD_ACD_SUCCEED,
NET_EVENT_IPV4_CMD_ACD_FAILED,
NET_EVENT_IPV4_CMD_ACD_CONFLICT,
NET_EVENT_IPV4_CMD_PMTU_CHANGED,
};

/* L4 network events */
Expand Down Expand Up @@ -237,6 +239,10 @@
#define NET_EVENT_IPV6_PE_FILTER_DEL \
(_NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_PE_FILTER_DEL)

/** IPv6 Path MTU is changed. */
#define NET_EVENT_IPV6_PMTU_CHANGED \
(_NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_PMTU_CHANGED)

Check notice on line 245 in include/zephyr/net/net_event.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

include/zephyr/net/net_event.h:245 -#define NET_EVENT_IPV6_PMTU_CHANGED \ - (_NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_PMTU_CHANGED) +#define NET_EVENT_IPV6_PMTU_CHANGED (_NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_PMTU_CHANGED)
/** Event emitted when an IPv4 address is added to the system. */
#define NET_EVENT_IPV4_ADDR_ADD \
(_NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_ADDR_ADD)
Expand Down Expand Up @@ -296,6 +302,10 @@
#define NET_EVENT_IPV4_ACD_CONFLICT \
(_NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_ACD_CONFLICT)

/** IPv4 Path MTU is changed. */
#define NET_EVENT_IPV4_PMTU_CHANGED \
(_NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_PMTU_CHANGED)

Check notice on line 308 in include/zephyr/net/net_event.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

include/zephyr/net/net_event.h:308 -#define NET_EVENT_IPV4_PMTU_CHANGED \ - (_NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_PMTU_CHANGED) +#define NET_EVENT_IPV4_PMTU_CHANGED (_NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_PMTU_CHANGED)
/** Event emitted when the system is considered to be connected.
* The connected in this context means that the network interface is up,
* and the interface has either IPv4 or IPv6 address assigned to it.
Expand Down Expand Up @@ -441,6 +451,34 @@
bool is_deny_list;
};

/**
* @brief Network Management event information structure
* Used to pass information on network event
* NET_EVENT_IPV4_PMTU_CHANGED
* when CONFIG_NET_MGMT_EVENT_INFO enabled and event generator pass the
* information.
*/
struct net_event_ipv4_pmtu_info {
/** IPv4 address */
struct in_addr dst;
/** New MTU */
uint16_t mtu;
};

/**
* @brief Network Management event information structure
* Used to pass information on network event
* NET_EVENT_IPV6_PMTU_CHANGED
* when CONFIG_NET_MGMT_EVENT_INFO enabled and event generator pass the
* information.
*/
struct net_event_ipv6_pmtu_info {
/** IPv6 address */
struct in6_addr dst;
/** New MTU */
uint32_t mtu;
};

#ifdef __cplusplus
}
#endif
Expand Down
30 changes: 30 additions & 0 deletions include/zephyr/net/net_pkt.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@
uint8_t cooked_mode_pkt : 1;
#endif /* CONFIG_NET_CAPTURE_COOKED_MODE */

#if defined(CONFIG_NET_IPV4_PMTU)
/* Path MTU needed for this destination address */
uint8_t ipv4_pmtu : 1;
#endif /* CONFIG_NET_IPV4_PMTU */

Check notice on line 348 in include/zephyr/net/net_pkt.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

include/zephyr/net/net_pkt.h:348 - uint8_t ipv4_pmtu : 1; + uint8_t ipv4_pmtu: 1;

/* @endcond */
};

Expand Down Expand Up @@ -783,6 +788,31 @@
#endif
}

#if defined(CONFIG_NET_IPV4_PMTU)
static inline bool net_pkt_ipv4_pmtu(struct net_pkt *pkt)
{
return !!pkt->ipv4_pmtu;
}

static inline void net_pkt_set_ipv4_pmtu(struct net_pkt *pkt, bool value)
{
pkt->ipv4_pmtu = value;
}
#else
static inline bool net_pkt_ipv4_pmtu(struct net_pkt *pkt)
{
ARG_UNUSED(pkt);

return false;
}

static inline void net_pkt_set_ipv4_pmtu(struct net_pkt *pkt, bool value)
{
ARG_UNUSED(pkt);
ARG_UNUSED(value);
}
#endif /* CONFIG_NET_IPV4_PMTU */

#if defined(CONFIG_NET_IPV4_FRAGMENT)
static inline uint16_t net_pkt_ipv4_fragment_offset(struct net_pkt *pkt)
{
Expand Down
60 changes: 60 additions & 0 deletions include/zephyr/net/net_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,34 @@
net_stats_t sent;
};

/**
* @brief IPv6 Path MTU Discovery statistics
*/
struct net_stats_ipv6_pmtu {
/** Number of dropped IPv6 PMTU packets. */
net_stats_t drop;

/** Number of received IPv6 PMTU packets. */
net_stats_t recv;

/** Number of sent IPv6 PMTU packets. */
net_stats_t sent;
};

/**
* @brief IPv4 Path MTU Discovery statistics
*/
struct net_stats_ipv4_pmtu {
/** Number of dropped IPv4 PMTU packets. */
net_stats_t drop;

/** Number of received IPv4 PMTU packets. */
net_stats_t recv;

/** Number of sent IPv4 PMTU packets. */
net_stats_t sent;
};

/**
* @brief IPv6 multicast listener daemon statistics
*/
Expand Down Expand Up @@ -379,6 +407,16 @@
struct net_stats_ipv6_nd ipv6_nd;
#endif

#if defined(CONFIG_NET_STATISTICS_IPV6_PMTU)
/** IPv6 Path MTU Discovery statistics */
struct net_stats_ipv6_pmtu ipv6_pmtu;
#endif

#if defined(CONFIG_NET_STATISTICS_IPV4_PMTU)
/** IPv4 Path MTU Discovery statistics */
struct net_stats_ipv4_pmtu ipv4_pmtu;
#endif

#if defined(CONFIG_NET_STATISTICS_MLD)
/** IPv6 MLD statistics */
struct net_stats_ipv6_mld ipv6_mld;
Expand Down Expand Up @@ -665,6 +703,8 @@
NET_REQUEST_STATS_CMD_GET_IPV4,
NET_REQUEST_STATS_CMD_GET_IPV6,
NET_REQUEST_STATS_CMD_GET_IPV6_ND,
NET_REQUEST_STATS_CMD_GET_IPV6_PMTU,
NET_REQUEST_STATS_CMD_GET_IPV4_PMTU,
NET_REQUEST_STATS_CMD_GET_ICMP,
NET_REQUEST_STATS_CMD_GET_UDP,
NET_REQUEST_STATS_CMD_GET_TCP,
Expand Down Expand Up @@ -732,6 +772,26 @@
/** @endcond */
#endif /* CONFIG_NET_STATISTICS_IPV6_ND */

#if defined(CONFIG_NET_STATISTICS_IPV6_PMTU)
/** Request IPv6 Path MTU Discovery statistics */
#define NET_REQUEST_STATS_GET_IPV6_PMTU \
(_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_IPV6_PMTU)

Check notice on line 779 in include/zephyr/net/net_stats.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

include/zephyr/net/net_stats.h:779 -#define NET_REQUEST_STATS_GET_IPV6_PMTU \ - (_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_IPV6_PMTU) +#define NET_REQUEST_STATS_GET_IPV6_PMTU (_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_IPV6_PMTU)
/** @cond INTERNAL_HIDDEN */
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_IPV6_PMTU);
/** @endcond */
#endif /* CONFIG_NET_STATISTICS_IPV6_PMTU */

#if defined(CONFIG_NET_STATISTICS_IPV4_PMTU)
/** Request IPv4 Path MTU Discovery statistics */
#define NET_REQUEST_STATS_GET_IPV4_PMTU \
(_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_IPV4_PMTU)

Check notice on line 789 in include/zephyr/net/net_stats.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

include/zephyr/net/net_stats.h:789 -#define NET_REQUEST_STATS_GET_IPV4_PMTU \ - (_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_IPV4_PMTU) +#define NET_REQUEST_STATS_GET_IPV4_PMTU (_NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_IPV4_PMTU)
/** @cond INTERNAL_HIDDEN */
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_IPV4_PMTU);
/** @endcond */
#endif /* CONFIG_NET_STATISTICS_IPV4_PMTU */

#if defined(CONFIG_NET_STATISTICS_ICMP)
/** Request ICMPv4 and ICMPv6 statistics */
#define NET_REQUEST_STATS_GET_ICMP \
Expand Down
13 changes: 13 additions & 0 deletions include/zephyr/net/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,12 @@ struct in_pktinfo {
struct in_addr ipi_addr; /**< Header Destination address */
};

/** Retrieve the current known path MTU of the current socket. Returns an
* integer. IP_MTU is valid only for getsockopt and can be employed only when
* the socket has been connected.
*/
#define IP_MTU 14

/** Set IPv4 multicast TTL value. */
#define IP_MULTICAST_TTL 33
/** Join IPv4 multicast group. */
Expand Down Expand Up @@ -1236,6 +1242,13 @@ struct ipv6_mreq {
int ipv6mr_ifindex;
};

/** For getsockopt(), retrieve the current known IPv6 path MTU of the given socket.
* Valid only when the socket has been connected.
* For setsockopt(), set the MTU to be used for the socket. The MTU is limited by
* the device MTU or the path MTU when path MTU discovery is enabled.
*/
#define IPV6_MTU 24

/** Don't support IPv4 access */
#define IPV6_V6ONLY 26

Expand Down
13 changes: 13 additions & 0 deletions samples/net/stats/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
GET_STAT(iface, ipv6_nd.sent),
GET_STAT(iface, ipv6_nd.drop));
#endif /* CONFIG_NET_IPV6_ND */
#if defined(CONFIG_NET_IPV6_PMTU)
printk("IPv6 PMTU recv %d\tsent\t%d\tdrop\t%d\n",
GET_STAT(iface, ipv6_pmtu.recv),
GET_STAT(iface, ipv6_pmtu.sent),
GET_STAT(iface, ipv6_pmtu.drop));
#endif /* CONFIG_NET_IPV6_PMTU */

Check notice on line 51 in samples/net/stats/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

samples/net/stats/src/main.c:51 - printk("IPv6 PMTU recv %d\tsent\t%d\tdrop\t%d\n", - GET_STAT(iface, ipv6_pmtu.recv), - GET_STAT(iface, ipv6_pmtu.sent), - GET_STAT(iface, ipv6_pmtu.drop)); + printk("IPv6 PMTU recv %d\tsent\t%d\tdrop\t%d\n", GET_STAT(iface, ipv6_pmtu.recv), + GET_STAT(iface, ipv6_pmtu.sent), GET_STAT(iface, ipv6_pmtu.drop));
#if defined(CONFIG_NET_STATISTICS_MLD)
printk("IPv6 MLD recv %d\tsent\t%d\tdrop\t%d\n",
GET_STAT(iface, ipv6_mld.recv),
Expand All @@ -68,6 +74,13 @@
GET_STAT(iface, ip_errors.chkerr),
GET_STAT(iface, ip_errors.protoerr));

#if defined(CONFIG_NET_IPV4_PMTU)
printk("IPv4 PMTU recv %d\tsent\t%d\tdrop\t%d\n",
GET_STAT(iface, ipv4_pmtu.recv),
GET_STAT(iface, ipv4_pmtu.sent),
GET_STAT(iface, ipv4_pmtu.drop));
#endif /* CONFIG_NET_IPV4_PMTU */

Check notice on line 82 in samples/net/stats/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

samples/net/stats/src/main.c:82 - printk("IPv4 PMTU recv %d\tsent\t%d\tdrop\t%d\n", - GET_STAT(iface, ipv4_pmtu.recv), - GET_STAT(iface, ipv4_pmtu.sent), - GET_STAT(iface, ipv4_pmtu.drop)); + printk("IPv4 PMTU recv %d\tsent\t%d\tdrop\t%d\n", GET_STAT(iface, ipv4_pmtu.recv), + GET_STAT(iface, ipv4_pmtu.sent), GET_STAT(iface, ipv4_pmtu.drop));

printk("ICMP recv %d\tsent\t%d\tdrop\t%d\n",
GET_STAT(iface, icmp.recv),
GET_STAT(iface, icmp.sent),
Expand Down
1 change: 1 addition & 0 deletions subsys/net/ip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ zephyr_library_sources_ifdef(CONFIG_NET_IPV6_PE ipv6_pe.c)
zephyr_library_sources_ifdef(CONFIG_NET_IPV6_FRAGMENT ipv6_fragment.c)
zephyr_library_sources_ifdef(CONFIG_NET_IPV4_FRAGMENT ipv4_fragment.c)
zephyr_library_sources_ifdef(CONFIG_NET_MGMT_EVENT net_mgmt.c)
zephyr_library_sources_ifdef(CONFIG_NET_PMTU pmtu.c)
zephyr_library_sources_ifdef(CONFIG_NET_ROUTE route.c)
zephyr_library_sources_ifdef(CONFIG_NET_STATISTICS net_stats.c)
zephyr_library_sources_ifdef(CONFIG_NET_TCP tcp.c)
Expand Down
21 changes: 21 additions & 0 deletions subsys/net/ip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ config NET_NATIVE_IPV4
depends on NET_NATIVE
default y if NET_IPV4

config NET_PMTU
bool
select NET_MGMT
select NET_MGMT_EVENT
select NET_MGMT_EVENT_INFO
default y
depends on NET_IPV6_PMTU || NET_IPV4_PMTU

if NET_PMTU
module = NET_PMTU
module-dep = NET_LOG
module-str = Log level for PMTU
module-help = Enables PMTU to output debug messages.
source "subsys/net/Kconfig.template.log_config.net"
endif # NET_PMTU

config NET_NATIVE_TCP
bool
depends on NET_NATIVE
Expand Down Expand Up @@ -252,6 +268,11 @@ config NET_SHELL_PKT_ALLOC_SUPPORTED
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_DEBUG_NET_PKT_ALLOC

config NET_SHELL_PMTU_SUPPORTED
bool "PMTU config"
default y
depends on NET_SHELL_SHOW_DISABLED_COMMANDS || NET_PMTU

config NET_SHELL_PPP_SUPPORTED
bool "PPP config"
default y
Expand Down
12 changes: 12 additions & 0 deletions subsys/net/ip/Kconfig.ipv4
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,18 @@ config NET_IPV4_FRAGMENT_TIMEOUT
How long to wait for IPv4 fragment to arrive before the reassembly
will timeout. This value is in seconds.

config NET_IPV4_PMTU
bool "IPv4 Path MTU Discovery"
help
Enables IPv4 Path MTU Discovery (see RFC 1191)

config NET_IPV4_PMTU_DESTINATION_CACHE_ENTRIES
int "Number of IPv4 PMTU destination cache entries"
default 3
depends on NET_IPV4_PMTU
help
How many PMTU entries we can track for each destination address.

module = NET_IPV4
module-dep = NET_LOG
module-str = Log level for core IPv4
Expand Down
12 changes: 12 additions & 0 deletions subsys/net/ip/Kconfig.ipv6
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ config NET_IPV6_MTU
The value should normally be 1280 which is the minimum IPv6 packet
size that implementations need to support without fragmentation.

config NET_IPV6_PMTU
bool "IPv6 Path MTU Discovery"
help
Enables IPv6 Path MTU Discovery (see RFC 8201)

config NET_IPV6_PMTU_DESTINATION_CACHE_ENTRIES
int "Number of IPv6 PMTU destination cache entries"
default 3
depends on NET_IPV6_PMTU
help
How many PMTU entries we can track for each destination address.

config NET_INITIAL_HOP_LIMIT
int "Initial IPv6 hop limit value for unicast packets"
default 64
Expand Down
14 changes: 14 additions & 0 deletions subsys/net/ip/Kconfig.stats
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ config NET_STATISTICS_IPV6_ND
help
Keep track of IPv6 Neighbor Discovery related statistics

config NET_STATISTICS_IPV6_PMTU
bool "IPv6 PMTU statistics"
depends on NET_IPV6_PMTU
default y
help
Keep track of IPv6 Path MTU Discovery related statistics

config NET_STATISTICS_IPV4_PMTU
bool "IPv4 PMTU statistics"
depends on NET_IPV4_PMTU
default y
help
Keep track of IPv4 Path MTU Discovery related statistics

config NET_STATISTICS_ICMP
bool "ICMP statistics"
depends on NET_IPV6 || NET_IPV4
Expand Down
Loading
Loading