Skip to content

Commit

Permalink
Wi-SUN MTU size update and IPv6 minium MTU routing skip
Browse files Browse the repository at this point in the history
Wi-SUN interface MTU config to 1576.

Minium link MTU usage skipped for IPv6 routing.

Tunneled IPv6 Packet will follow MTU size 1280. Bigger Ones will be fragmented.
  • Loading branch information
Juha Heiskanen committed Feb 3, 2021
1 parent 3ad28c1 commit 890aad1
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 14 deletions.
2 changes: 2 additions & 0 deletions source/6LoWPAN/ws/ws_bootstrap.c
Expand Up @@ -2337,6 +2337,8 @@ int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode)
goto init_fail;
}

cur->ipv6_neighbour_cache.link_mtu = cur->max_link_mtu = WS_MPX_MAX_MTU;

cur->if_up = ws_bootstrap_up;
cur->if_down = ws_bootstrap_down;
cur->ws_info->neighbor_storage = neigh_info;
Expand Down
8 changes: 8 additions & 0 deletions source/6LoWPAN/ws/ws_common_defines.h
Expand Up @@ -239,6 +239,13 @@ typedef struct ws_bs_ie {
#define MPX_KEY_MANAGEMENT_ENC_USER_ID 0x0001 /**< MPX Key management user ID */
#define MPX_LOWPAN_ENC_USER_ID 0xA0ED /**< MPX Lowpan User Id */

/*
* Wi-SUN MPX MTU size
*
*/

#define WS_MPX_MAX_MTU 1576

#define WS_FAN_VERSION_1_0 1

#define WS_NEIGHBOR_LINK_TIMEOUT 2200
Expand Down Expand Up @@ -373,4 +380,5 @@ typedef struct ws_bs_ie {
#define BR_EAPOL_RELAY_SOCKET_PORT 10255
#define PAE_AUTH_SOCKET_PORT 10254


#endif /* WS_COMMON_DEFINES_H_ */
13 changes: 12 additions & 1 deletion source/Common_Protocols/ipv6.c
Expand Up @@ -613,6 +613,16 @@ buffer_t *ipv6_forwarding_down(buffer_t *buf)

/* Routing code may say it needs to tunnel to add headers - loop back to IP layer if requested */
if (exthdr_result == IPV6_EXTHDR_MODIFY_TUNNEL) {

if (buffer_data_length(buf) > IPV6_MIN_LINK_MTU) {
/* recover IP addresses that icmpv6_error needs, which routing code will have overwritten */
buf->src_sa.addr_type = ADDR_IPV6;
memcpy(buf->src_sa.address, buffer_data_pointer(buf) + IPV6_HDROFF_SRC_ADDR, 16);
buf->dst_sa.addr_type = ADDR_IPV6;
memcpy(buf->dst_sa.address, buffer_data_pointer(buf) + IPV6_HDROFF_DST_ADDR, 16);
return icmpv6_error(buf, NULL, ICMPV6_TYPE_ERROR_PACKET_TOO_BIG, 0, IPV6_MIN_LINK_MTU);
}

/* Avoid an infinite loop in the event of routing code failure - never
* let them ask for tunnelling more than once.
*/
Expand All @@ -623,6 +633,7 @@ buffer_t *ipv6_forwarding_down(buffer_t *buf)
buf->options.tunnelled = true;

buf->options.ip_extflags = 0;
buf->options.ipv6_use_min_mtu = -1;

/* Provide tunnel source, unless already set */
if (buf->src_sa.addr_type == ADDR_NONE) {
Expand Down Expand Up @@ -1003,7 +1014,7 @@ static buffer_t *ipv6_consider_forwarding_unicast_packet(buffer_t *buf, protocol

/* route_info.pmtu will cover limits from both the interface and the
* route. As a bonus, it will also cover any PMTUD we happen to have done
* to that destination ourselves, as well as mop up any tunnelling issues.
* to that destination ourselves. Extra limits due to tunnelling are checked on tunnel entry in ipv6_down.
*/
if (routing->route_info.pmtu < buffer_data_length(buf)) {
buf->interface = cur;
Expand Down
2 changes: 1 addition & 1 deletion source/Common_Protocols/ipv6.h
Expand Up @@ -57,7 +57,7 @@ typedef enum ipv6_exthdr_stage {
* If it needs to insert headers that are not present, it can force insertion
* into a tunnel, by:
* setting dst_sa and src_sa appropriate for the tunnel endpoints
* XXX does this work out okay with dest cache and PMTU?
* src_sa.addr_type can be set to ADDR_NONE to auto-select tunnel source address
* updating route info like next hop if necessary (probably not)
* returning IPV6_EXTHDR_MODIFY_TUNNEL
* During new header formation for the tunnel, IPV6_EXTHDR_INSERT will be
Expand Down
1 change: 1 addition & 0 deletions source/MPL/mpl.c
Expand Up @@ -1065,6 +1065,7 @@ static buffer_t *mpl_exthdr_provider(buffer_t *buf, ipv6_exthdr_stage_t stage, i
if (!domain) {
// We will need to tunnel - do nothing on the inner packet
*result = 0;
buf->options.ipv6_use_min_mtu = 1;
return buf;
}

Expand Down
2 changes: 2 additions & 0 deletions source/RPL/rpl_data.c
Expand Up @@ -374,6 +374,7 @@ static buffer_t *rpl_data_exthdr_provider_hbh_2(buffer_t *buf, rpl_instance_t *i
case IPV6_EXTHDR_INSERT: {
if (!destination_in_instance) {
/* We don't add a header - we'll do it on the tunnel */
buf->options.ipv6_use_min_mtu = 1;
*result = 0;
return buf;
}
Expand Down Expand Up @@ -965,6 +966,7 @@ static buffer_t *rpl_data_exthdr_provider_srh(buffer_t *buf, ipv6_exthdr_stage_t
if (!buf->options.tunnelled) {
if (stage == IPV6_EXTHDR_SIZE || stage == IPV6_EXTHDR_INSERT) {
*result = 0;
buf->options.ipv6_use_min_mtu = 1;
return buf;
}
}
Expand Down
13 changes: 1 addition & 12 deletions source/ipv6_stack/ipv6_routing_table.c
Expand Up @@ -1195,17 +1195,6 @@ static const bool ipv6_route_probing[ROUTE_MAX] = {
[ROUTE_RPL_INSTANCE] = true,
};

/* Which route types get minimum link MTU by default */
/* Makes life easier for tunnel-based systems like RPL */
static const bool ipv6_route_min_mtu[ROUTE_MAX] = {
[ROUTE_RPL_DAO] = true,
[ROUTE_RPL_DAO_SR] = true,
[ROUTE_RPL_DIO] = true,
[ROUTE_RPL_ROOT] = true,
[ROUTE_RPL_INSTANCE] = true,
[ROUTE_MPL] = true,
};

// Remember when a route source has deleted an entry - allows buffers still in
// event queue to have their route info invalidated.
static bool ipv6_route_source_invalidated[ROUTE_MAX];
Expand Down Expand Up @@ -1647,7 +1636,7 @@ ipv6_route_t *ipv6_route_add_metric(const uint8_t *prefix, uint8_t prefix_len, i
route->info.info = info;
route->info.source_id = source_id;
route->info.interface_id = interface_id;
route->info.pmtu = ipv6_route_min_mtu[source] ? IPV6_MIN_LINK_MTU : 0xFFFF;
route->info.pmtu = 0xFFFF;
if (next_hop) {
route->on_link = false;
memcpy(route->info.next_hop_addr, next_hop, 16);
Expand Down

0 comments on commit 890aad1

Please sign in to comment.