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
alfred: Support interface IDs with more than two digits #354
Conversation
@ecsv could you take a look at this PR? |
I think you should ask @NeoRaider because he implemented the original code for this. |
Hm, just had a look at the change and the commit message. The commit forgot to update the comment above the awk code. And the commit message doesn't explain the problem very well. The current output of looks like this
The comment currently explains that the lines have to start with fe80 and then are followed with 37 uninteresting characters. We can therefore ignore the initial 39 characters and not matching lines before going through the next parts of the check:
The current code then checks that the initial 41 characters are followed by a space and then assumes that a two digit hex number (flags) follows. It will only accept lines when this two digit hex number is not starting with a digit that has the bit 0x4 set. But the change now allows to have [0-9a-f] after the initial 41 characters. This means that $5 (flags) can be shifted by a single character. This can happen because ifindex ($2) has more than two digits. I would say this will become ugly when more of these checks have to be added - especially because 3 hex digits for $2 (ifindex) is not the actual limit . Instead, maybe it can be changed to:
A problematic line which this change tries to handle is:
But it doesn't get this line:
But it incorrectly accepts line:
I would therefore conclude that the change is incorrect |
Wouldn't this work?
|
No, because this would also match:
You may have wanted to use |
ah, right. we want to match 0x40, not 0x4 |
I propose this code:
While not directly related, I also noticed that $6 will not properly match interface names containing whitespace (spaces, tabs...), and I assume interface names with newlines will break the if_inet6 format hopelessly... but maybe we can just ignore the whitespace case because nobody is that insane :) |
Haven't had time to follow in detail (my awk knowledge is limited), but will try to do that later. I would test the proposed code and in case of success redo my commit with updated comment as mentioned earlier. Any objections? |
@adrianschmutzler sounds good! |
I was contacted via IRC and asked what comment I am talking about (the one which needs adjustments). This one here: https://github.com/openwrt-routing/packages/blob/448ca58e4cb205eb71f0b889c66e64ce9a028780/alfred/files/alfred.init#L49 |
@ecsv ah, the comment in the source code. Not a comment here in the issue tracker. |
I like NeoRaider's solution and it works for me, except that I have to stick with the RET variables and only call exit in the END block. Calling exit directly didn't work for me, don't know why. However, I can live with the variable still being used. Will update the commit soon. |
Occationally /proc/net/if_inet6 contains interface IDs with three digits. In this case, the regex in wait_for_ll_address() does not work anymore and alfred is not starting. This patch changes the evaluation so that fields are used instead of the mere position by counting characters. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Patch is updated. Slightly updated the commit message, too. Since now the solution isn't originating from me any more, should I mention someone in the commit message? |
@adrianschmutzler no need to include another author for this kind of thing. I don't think @NeoRaider will mind. |
How about merging? |
Occationally /proc/net/if_inet6 contains interface IDs with
three digits. In this case, the regex in wait_for_ll_address()
does not work anymore and alfred is not starting.