Skip to content

net: custom NET_LINK_ADDR_MAX_LENGTH with CONFIG_MODEM_CELLULAR #92172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jhirsi
Copy link
Contributor

@jhirsi jhirsi commented Jun 25, 2025

Max 16 bytes NET_LINK_ADDR_MAX_LENGTH with CONFIG_MODEM_CELLULAR to reflect IMEI length.

Max 16 bytes NET_LINK_ADDR_MAX_LENGTH with CONFIG_MODEM_CELLULAR
to reflect IMEI length.

Signed-off-by: Jani Hirsimäki <[email protected]>
Copy link

Copy link
Member

@jukkar jukkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding -1 for now to avoid accidental merging.

@@ -30,7 +30,9 @@ extern "C" {
*/

/** Maximum length of the link address */
#if defined(CONFIG_NET_L2_PHY_IEEE802154) || defined(CONFIG_NET_L2_PPP)
#if defined(CONFIG_MODEM_CELLULAR)
#define NET_LINK_ADDR_MAX_LENGTH 16
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How well is this tested with IPv6? The 16 byte link address is not common and because this causes all network interfaces to have max length larger than usual.

I am a bit worried about the NS & RA handling in

lladdr->len = NET_LINK_ADDR_MAX_LENGTH;

The padding variable might overflow easily

padding = len * 8U - 2 - lladdr->len;

Is this change fixing a real issue or was it just done because we can?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add a test for this so that we can verify that at least the tests work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is real issue with ipv6 and when using NCS SLM application from ext-mcu and in this case from cellular modem.
In this kind of usage, recent changes to net_link_addr struct to not use pointers caused that these changes are needed and the assertion in:
ASSERTION FAIL [linkaddr->len >= 6] @ WEST_TOPDIR/zephyr/subsys/net/l2/ppp/ipv6cp.c:40

I did't find any cellular modem related tests.

Copy link
Member

@jukkar jukkar Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did't find any cellular modem related tests.

Could we enable the option for relevant IPv6 tests so that this gets tested?
For example adding a new test setup with the cellular option to tests/net/ipv6/testcase.yaml, there might be other tests too where this could be done, this directory does at least some of the IPv6 neighbor testing.
By just adding new max value and not having any automated testing for it is a no-go.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is real issue with ipv6 and when using NCS SLM application from ext-mcu and in this case from cellular modem.

I am sure things work ok if only using cellular modem. I am mostly concerned what happens with multiple interface scenario like having wifi enabled at the same time.

Copy link
Member

@jukkar jukkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some manual testing by setting link address to 16 bytes. Everything seems to work ok with Ethernet.

Comment on lines +885 to 891
err = net_if_set_link_addr(modem_ppp_get_iface(data->ppp), data->imei,
ARRAY_SIZE(data->imei),
NET_LINK_UNKNOWN);
if (err) {
LOG_WRN("Failed to set link address on PPP interface (%d)", err);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding the new address length, I think this should be changed to use a portion of the IMEI to set the 'MAC address' of the interface. For example, use the least significant digits of the IMEI to derive a MAC address.

@rlubos
Copy link
Collaborator

rlubos commented Jun 25, 2025

Just my 2c, MODEM_CELLULAR seems to be dependent on NET_L2_PPP, so IMHO it should comply with whatever LL address size the PPP L2 specifies (which currently is 8 bytes for whatever reason).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants