Skip to content
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

Linux: simplify ffNetifGetDefaultRouteImpl #1336

Conversation

apocelipes
Copy link
Contributor

Use fgets to skip the first line of "/proc/net/route" since its line size is fixed.

Here's the kernel code that generate the "/proc/net/route":
image

There are 127 chars and a newline, 127+1=128.

image

https://github.com/torvalds/linux/blob/7234e2ea0edd00bfb6bb2159e55878c19885ce68/net/ipv4/fib_trie.c#L2968

They also say that the file format won't be changed in future, so use fgets is safe and it is simpler than a getc-loop.

@CarterLi CarterLi closed this in 3a914f2 Oct 13, 2024
@apocelipes
Copy link
Contributor Author

I dont think using fseek on procfs/sysfs is a good idea. Actually you can find tons of problems that lseek/fseek doesn't work as expected, that why I use fgets ranther than fseek. Fortunately, it did not cause problems on the router. However if you strongly prefer to use fseek YOU CAN EXPLAIN WHY AND ASK ME TO CHANGE TO IT, OR YOU CAN ASK ME WHY NOT USE FSEEK. JUST DONT SAY NOTHING AND CHANGE IT BY YOURSELF, THAT'S NOT HOW OPEN SOURCE COMMUNITIES WORK.

@apocelipes
Copy link
Contributor Author

I don't mean to blame anyone but this has happened so many times that it has made me distrust the contribution process and feel frustrated.

@apocelipes apocelipes deleted the simplify-ffNetifGetDefaultRouteImpl branch October 13, 2024 11:03
@CarterLi
Copy link
Member

Actually you can find tons of problems that lseek/fseek doesn't work as expected

Only if the files constantly changes like /proc/meminfo. /proc/net/route is not one of them.

JUST DONT SAY NOTHING AND CHANGE IT BY YOURSELF, THAT'S NOT HOW OPEN SOURCE COMMUNITIES WORK.

That's my style. I just have no enough patience to argue something one by one.

Don't be mad, ok?

@apocelipes
Copy link
Contributor Author

I agree the reason you chose fseek. I also respect your working style. But I still think lefting a simple comment like "I hava a better idea"/"I dont like this" does not cost so much time. And to me, I always enable the edit permisson that if you think only a little parts need be modified you can commit/edit on the pr directly without asking me. That means I can know what happend by emails/notifiications, not only see an email tells me the issue/pr was closed with no other info.

@CarterLi
Copy link
Member

not only see an email tells me the issue/pr was closed with no other info

Still better than absolutely no email.

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

Successfully merging this pull request may close these issues.

2 participants