Skip to content

Commit 890aad1

Browse files
author
Juha Heiskanen
committed
Wi-SUN MTU size update and IPv6 minium MTU routing skip
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.
1 parent 3ad28c1 commit 890aad1

File tree

7 files changed

+27
-14
lines changed

7 files changed

+27
-14
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,6 +2337,8 @@ int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode)
23372337
goto init_fail;
23382338
}
23392339

2340+
cur->ipv6_neighbour_cache.link_mtu = cur->max_link_mtu = WS_MPX_MAX_MTU;
2341+
23402342
cur->if_up = ws_bootstrap_up;
23412343
cur->if_down = ws_bootstrap_down;
23422344
cur->ws_info->neighbor_storage = neigh_info;

source/6LoWPAN/ws/ws_common_defines.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,13 @@ typedef struct ws_bs_ie {
239239
#define MPX_KEY_MANAGEMENT_ENC_USER_ID 0x0001 /**< MPX Key management user ID */
240240
#define MPX_LOWPAN_ENC_USER_ID 0xA0ED /**< MPX Lowpan User Id */
241241

242+
/*
243+
* Wi-SUN MPX MTU size
244+
*
245+
*/
246+
247+
#define WS_MPX_MAX_MTU 1576
248+
242249
#define WS_FAN_VERSION_1_0 1
243250

244251
#define WS_NEIGHBOR_LINK_TIMEOUT 2200
@@ -373,4 +380,5 @@ typedef struct ws_bs_ie {
373380
#define BR_EAPOL_RELAY_SOCKET_PORT 10255
374381
#define PAE_AUTH_SOCKET_PORT 10254
375382

383+
376384
#endif /* WS_COMMON_DEFINES_H_ */

source/Common_Protocols/ipv6.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,16 @@ buffer_t *ipv6_forwarding_down(buffer_t *buf)
613613

614614
/* Routing code may say it needs to tunnel to add headers - loop back to IP layer if requested */
615615
if (exthdr_result == IPV6_EXTHDR_MODIFY_TUNNEL) {
616+
617+
if (buffer_data_length(buf) > IPV6_MIN_LINK_MTU) {
618+
/* recover IP addresses that icmpv6_error needs, which routing code will have overwritten */
619+
buf->src_sa.addr_type = ADDR_IPV6;
620+
memcpy(buf->src_sa.address, buffer_data_pointer(buf) + IPV6_HDROFF_SRC_ADDR, 16);
621+
buf->dst_sa.addr_type = ADDR_IPV6;
622+
memcpy(buf->dst_sa.address, buffer_data_pointer(buf) + IPV6_HDROFF_DST_ADDR, 16);
623+
return icmpv6_error(buf, NULL, ICMPV6_TYPE_ERROR_PACKET_TOO_BIG, 0, IPV6_MIN_LINK_MTU);
624+
}
625+
616626
/* Avoid an infinite loop in the event of routing code failure - never
617627
* let them ask for tunnelling more than once.
618628
*/
@@ -623,6 +633,7 @@ buffer_t *ipv6_forwarding_down(buffer_t *buf)
623633
buf->options.tunnelled = true;
624634

625635
buf->options.ip_extflags = 0;
636+
buf->options.ipv6_use_min_mtu = -1;
626637

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

10041015
/* route_info.pmtu will cover limits from both the interface and the
10051016
* route. As a bonus, it will also cover any PMTUD we happen to have done
1006-
* to that destination ourselves, as well as mop up any tunnelling issues.
1017+
* to that destination ourselves. Extra limits due to tunnelling are checked on tunnel entry in ipv6_down.
10071018
*/
10081019
if (routing->route_info.pmtu < buffer_data_length(buf)) {
10091020
buf->interface = cur;

source/Common_Protocols/ipv6.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ typedef enum ipv6_exthdr_stage {
5757
* If it needs to insert headers that are not present, it can force insertion
5858
* into a tunnel, by:
5959
* setting dst_sa and src_sa appropriate for the tunnel endpoints
60-
* XXX does this work out okay with dest cache and PMTU?
60+
* src_sa.addr_type can be set to ADDR_NONE to auto-select tunnel source address
6161
* updating route info like next hop if necessary (probably not)
6262
* returning IPV6_EXTHDR_MODIFY_TUNNEL
6363
* During new header formation for the tunnel, IPV6_EXTHDR_INSERT will be

source/MPL/mpl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,7 @@ static buffer_t *mpl_exthdr_provider(buffer_t *buf, ipv6_exthdr_stage_t stage, i
10651065
if (!domain) {
10661066
// We will need to tunnel - do nothing on the inner packet
10671067
*result = 0;
1068+
buf->options.ipv6_use_min_mtu = 1;
10681069
return buf;
10691070
}
10701071

source/RPL/rpl_data.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ static buffer_t *rpl_data_exthdr_provider_hbh_2(buffer_t *buf, rpl_instance_t *i
374374
case IPV6_EXTHDR_INSERT: {
375375
if (!destination_in_instance) {
376376
/* We don't add a header - we'll do it on the tunnel */
377+
buf->options.ipv6_use_min_mtu = 1;
377378
*result = 0;
378379
return buf;
379380
}
@@ -965,6 +966,7 @@ static buffer_t *rpl_data_exthdr_provider_srh(buffer_t *buf, ipv6_exthdr_stage_t
965966
if (!buf->options.tunnelled) {
966967
if (stage == IPV6_EXTHDR_SIZE || stage == IPV6_EXTHDR_INSERT) {
967968
*result = 0;
969+
buf->options.ipv6_use_min_mtu = 1;
968970
return buf;
969971
}
970972
}

source/ipv6_stack/ipv6_routing_table.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,17 +1195,6 @@ static const bool ipv6_route_probing[ROUTE_MAX] = {
11951195
[ROUTE_RPL_INSTANCE] = true,
11961196
};
11971197

1198-
/* Which route types get minimum link MTU by default */
1199-
/* Makes life easier for tunnel-based systems like RPL */
1200-
static const bool ipv6_route_min_mtu[ROUTE_MAX] = {
1201-
[ROUTE_RPL_DAO] = true,
1202-
[ROUTE_RPL_DAO_SR] = true,
1203-
[ROUTE_RPL_DIO] = true,
1204-
[ROUTE_RPL_ROOT] = true,
1205-
[ROUTE_RPL_INSTANCE] = true,
1206-
[ROUTE_MPL] = true,
1207-
};
1208-
12091198
// Remember when a route source has deleted an entry - allows buffers still in
12101199
// event queue to have their route info invalidated.
12111200
static bool ipv6_route_source_invalidated[ROUTE_MAX];
@@ -1647,7 +1636,7 @@ ipv6_route_t *ipv6_route_add_metric(const uint8_t *prefix, uint8_t prefix_len, i
16471636
route->info.info = info;
16481637
route->info.source_id = source_id;
16491638
route->info.interface_id = interface_id;
1650-
route->info.pmtu = ipv6_route_min_mtu[source] ? IPV6_MIN_LINK_MTU : 0xFFFF;
1639+
route->info.pmtu = 0xFFFF;
16511640
if (next_hop) {
16521641
route->on_link = false;
16531642
memcpy(route->info.next_hop_addr, next_hop, 16);

0 commit comments

Comments
 (0)