Skip to content

Commit 1504833

Browse files
mlaschcfriedt
authored andcommitted
drivers: net: ppp: Fix link-layer address configuration
Restore setting the ppp link-local address either to CONFIG_PPP_MAC_ADDR or to a random value 00:00:5e:00:53:XX instead of leaving it uninitialized. Recently the memory handling for the link-layer addresses was changed from an approach of copying pointers to managing the memory as a member of the `net_linkaddr` struct (ref ac3cb9d). The piece of code this patch touches however, relied on the use of the pointers to function properly. With the recent change, the MAC address was copied to the new member location before it was even set (either from Kconfig or selected randomly). As a result, the link-layer address was kept initialized to zero, which resulted in a IPv6 address of fe80::ff:fe00:0 which is exactly the link-local EUI-64 representation of the MAC address 00:00:00:00:00:00 (without flipping the "universal/local" bit). Signed-off-by: Marc Lasch <[email protected]>
1 parent 958bec0 commit 1504833

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

drivers/net/ppp.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -974,17 +974,9 @@ static int ppp_driver_init(const struct device *dev)
974974
return 0;
975975
}
976976

977-
static inline struct net_linkaddr *ppp_get_mac(struct ppp_driver_context *ppp)
978-
{
979-
(void)net_linkaddr_set(&ppp->ll_addr, ppp->mac_addr, sizeof(ppp->mac_addr));
980-
981-
return &ppp->ll_addr;
982-
}
983-
984977
static void ppp_iface_init(struct net_if *iface)
985978
{
986979
struct ppp_driver_context *ppp = net_if_get_device(iface)->data;
987-
struct net_linkaddr *ll_addr;
988980

989981
LOG_DBG("[%p] iface %p", ppp, iface);
990982

@@ -997,11 +989,6 @@ static void ppp_iface_init(struct net_if *iface)
997989
ppp->init_done = true;
998990
ppp->iface = iface;
999991

1000-
/* The mac address is not really used but network interface expects
1001-
* to find one.
1002-
*/
1003-
ll_addr = ppp_get_mac(ppp);
1004-
1005992
if (CONFIG_PPP_MAC_ADDR[0] != 0) {
1006993
if (net_bytes_from_str(ppp->mac_addr, sizeof(ppp->mac_addr),
1007994
CONFIG_PPP_MAC_ADDR) < 0) {
@@ -1018,7 +1005,10 @@ static void ppp_iface_init(struct net_if *iface)
10181005
ppp->mac_addr[5] = sys_rand8_get();
10191006
}
10201007

1021-
net_if_set_link_addr(iface, ll_addr->addr, ll_addr->len,
1008+
/* The MAC address is not really used, but the network interface expects to find one. */
1009+
(void)net_linkaddr_set(&ppp->ll_addr, ppp->mac_addr, sizeof(ppp->mac_addr));
1010+
1011+
net_if_set_link_addr(iface, ppp->ll_addr.addr, ppp->ll_addr.len,
10221012
NET_LINK_ETHERNET);
10231013

10241014
if (IS_ENABLED(CONFIG_NET_PPP_CAPTURE)) {

0 commit comments

Comments
 (0)