-
Notifications
You must be signed in to change notification settings - Fork 2k
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
cpu/stm32_common/periph: Fix addr filtering #13383
cpu/stm32_common/periph: Fix addr filtering #13383
Conversation
@benpicco, am I missing something? I don't have the background to make a meaningful contribution here. |
@benpicco : I was working with eth on stm32 a while ago, true. Still have the hardware, so I can test it. |
@wosym I am currently using a Nucleo-f207zg and noticed that every eth frame was passed on to the application regardless of the destination MAC. So the device always behaved as if it were in promiscuous mode. At first I thought that this behavior occurs only in my application, but the same thing happened when running the example under examples/default, which allows you to send a simple string directly over the link layer using unicast or broadcast. I hope this helps. |
@JannesVolkens: I tested both the master branch and this PR today, but could not reproduce the issue you describe. master and this PR both showed the same behavior. Testing procedure used:
Wireshark shows all three. However, the stm only reacts when sending the first one (which has the correct MAC-address for my board). Did I misunderstand the issue you're trying to fix? Or does it only occur under specific circumstances? |
@wosym Thank you for taking a look at it.
In case of the master every frame gets passed on to the application, where this PR only passes on the first received frame with the correct MAC-address. Do you happen to have the hardware to check this case? |
@JannesVolkens : Sadly, I only have one stm32 board with Ethernet at hand. |
@wosym I rebased on the current master and tested once again. I tried to reproduce your setup and connected my stm32 board directly to my laptop from where I sent raw ethernet frames to it. I’m still getting the same behavior as last time, meaning that every frame is being acted on by the application, regardless of the destination MAC-address. Whereas I get the correct behavior with this PR. Even a different board (Nucleo-f767zi) gave me the same results. |
@JannesVolkens : that's strange. Maybe someone else can try to reproduce the behavior? |
@wosym but your board still receives packets with this patch and the mac address displayed in |
@benpicco : Yes, this patch does not break anything for me (as far as I could tell at least). |
I've tested this with a nucleo-f767z1 and confirm this branch fixes the described bug. The board is directly connected to my laptop. With scapy I send two ethernet frames consecutively
Board output on master:
-> board receives frames that contain a different dst address. Board output on this branch:
-> board only receives frames that match its dst address. |
I didn't read the manual to confirm the code change, but ACK for the fix in general |
Let's consult the data sheet, page 911:
From my understanding HPF is correct, but we should also set the HM bit. (as I understand it otherwise the multicast address is not considered a multicast address and just compared directly with the device address - but might be misunderstanding the data sheet at that point) |
573710c
to
ad888c5
Compare
I think I misinterpreted the reference manual and from my understanding now the only bit that is needed is the PAM bit. According to table 144, section unicast in the second line, no filter bit is required to receive unicast frames. In addition, according to the section multicast, only the PAM bit has to be set to receive multicast frames. I was able to confirm both and was now able to receive unicast and multicast frames. Broadcast too, of course. |
Hm but do you really want to pass all multicast frames? |
- Set MACFFR to unicast filtering - Change byte-order of the MAC
c189034
to
4bb0d8b
Compare
Your’re right. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've re-tested this PR as described above.
sendp(Ether(dst="2A:10:2F:1B:03:45"), iface="< if >")
sendp(Ether(dst="56:13:3C:10:16:42"), iface="< if >")
sendp(Ether(dst="ff:ff:ff:ff:ff:ff"), iface="< if >")
Multicast frames are now completely filtered whereas broadcast and unicast frames pass. I also sent L2 packets from the Nucleo board to my laptop and src/dst addresses look as expected.
The MACFFR
register stays with its Reset value: 0x0000 0000
after initialization. Reading the description of all settings this seems to be a very basic but IMO reasonable setup for RIOT currently.
However, this PR makes me wonder how we handle Ethernet multicast addresses in general but answering this question is out of scope for this PR. ACK
somehow this broke ipv6 for me (just doing pings to to a nucleo-f767z1 runing the gcoap example) |
I give it a look. Linux -> RIOT ping? Which IPv6 address did you try to ping? |
i tryed to ping from linux to RIOT used the IPv6 address (no short form) |
Why does this patch leave MACFFR unconfigured? (started to check the documentation and it seems to me this would pass all frames (no filter at all)) |
@kfessel can you elaborate on you test setup, I cannot reproduce the issue. I connected the nucleo-f767z1 directly to my laptop with examples/gcoap running on 2020.01 release as well as current master
It remains with its reset value which enables basic filtering that only passes unicast addresses and broadcast. As indicated above, IMO a proper assignment of multicast next to the other addresses is currently missing. But blindly passing all frames is not reasonable at all in my opinion. |
Yet no idea why it worked between Linux<->RIOT (for me). Between two RIOT nodes we face the same issue. NDP maps to a multicast MAC address which is now blocked. So the neighbor table stays empty and IPv6 packets cannot be sent. We'll provide a fix |
i got a switch between my laptop and the board, but i am not sure what is happening, seems like in this neighbor/router sociation/advertisement some times the informations do not take the right path. sometimes it seems to work but other times not. When i wrote my complaint the thing did not work within mutiple resets and power cycles flashing multiple times (yes i know doing the same thing multible time and expecting differnt results is kind o stupid) then checked the history and went back before your patch and it worked (most the time (there is definetly an reset issue)) atm the master seems to work. i am also not sure if there is some issue due to the LAN8742A (PHY) beeing connected to an RC reset which the manufacturer advises angainst. |
one moment group mac ?? i had an issue and wrote a patch it is PR #13273 (merged) since this patch turns the byte order are you sure about that change? luid handels |
The address order change works fine (as reported above). @JannesVolkens will provide a quick fix regarding multicast filtering (would be great if you could test it then) and we should discuss multicast address assignment in a separate issue. |
ah ok now understand ( i just did a |
Yep, that must have been the reason here too. After flushing the Linux neighbor cache I couldn't ping anymore |
Contribution description
This PR fixes the eth reception of stm32_common. So far, every frame was being received, regardless of the destination MAC. To accomplish this the MACFFR was set to unicast filtering and the byte-order of the own MAC was corrected.
This PR was tested using the nucleo-f207zg and the example under examples/default
Testing procedure
None.
Issues/PRs references
None.