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

Implement userspace tool to display driver status and specify blocklist #53

Merged
merged 1 commit into from
Dec 27, 2023

Conversation

vax-r
Copy link
Collaborator

@vax-r vax-r commented Dec 8, 2023

Summary

Enable ability to use blacklist to block packets from specified interface.

Support blacklist in vwifi kernel module, used as interfaces pair such as "owl2 blocks owl1", allow maximum blacklist size to be 1024 bytes now and maintained as global content within struct owl_content.

Using userspace program to dynamically alter the blacklist maintaining in vwifi kernel module.

Testing

step 1

After mounting vwifi as kernel module in kernel, make sure the ping test works as normal as indicated in README.md.

step 2

compile blacklist_user.c and execute it

$ gcc blacklist_user.c -o blacklist_user.o
$ ./blacklist_user.o

After this step, we should have the blacklist loaded into vwifi kernel module.

step 3

Do the ping test again, it should block packets from the interface pair you specefied in ./scripts/blacklist.txt.
You can make the content of ./scripts/blacklist.txt empty and execute $ ./blacklist_user.o again, blacklist pairs should be removed then.

I think blacklist ability checking can be added as a tesing stage into verify.sh, I would love to help if needed.
Btw I found some type error in verify.sh, and correct "sucess" to "success".

Issue linked

Fix #48

@jserv jserv requested a review from rickywu0421 December 8, 2023 15:21
Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

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

  1. Use C-style comments. That is, /* comment */.
  2. Change Blacklist To Blocklist.
  3. Minimize the necessary changes. That is, send another pull request(s) for fixing typo.
  4. Avoid the statement such as strlen(owl->blacklist) == 0). Use !*(owl->blacklist) instead.

@vax-r vax-r force-pushed the Blacklist_feature branch 2 times, most recently from 352201b to 924d9f5 Compare December 9, 2023 06:40
@vax-r
Copy link
Collaborator Author

vax-r commented Dec 9, 2023

  1. Use C-style comments. That is, /* comment */.
  2. Change Blacklist To Blocklist.
  3. Minimize the necessary changes. That is, send another pull request(s) for fixing typo.
  4. Avoid the statement such as strlen(owl->blacklist) == 0). Use !*(owl->blacklist) instead.

I've made some changes according to the suggestion above, please take a look when you have time, Thank you!

@vax-r vax-r requested a review from jserv December 9, 2023 06:41
@jserv jserv changed the title Support blacklist in vwifi Support blocklist Dec 9, 2023
blocklist_user.c Outdated Show resolved Hide resolved
vwifi.c Outdated Show resolved Hide resolved
jserv

This comment was marked as outdated.

blocklist_user.c Outdated Show resolved Hide resolved
blocklist_user.c Outdated Show resolved Hide resolved
vwifi.c Outdated Show resolved Hide resolved
@vax-r vax-r force-pushed the Blacklist_feature branch from 924d9f5 to 282b735 Compare December 11, 2023 08:23
@vax-r
Copy link
Collaborator Author

vax-r commented Dec 11, 2023

@jserv
I've adjust the code according to the suggestion, and allow user-specific filename from command line.
Please take a look when you are available. Thank you!

@vax-r vax-r requested a review from jserv December 11, 2023 08:25
README.md Outdated Show resolved Hide resolved
vwifi.c Outdated Show resolved Hide resolved
@vax-r vax-r force-pushed the Blacklist_feature branch from 282b735 to ea22051 Compare December 17, 2023 09:47
@vax-r vax-r requested a review from jserv December 17, 2023 09:48
Makefile Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
vwifi.c Outdated Show resolved Hide resolved
vwifi.c Outdated Show resolved Hide resolved
Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

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

Read https://cbea.ms/git-commit/ carefully and refine your git commit messages.

@vax-r vax-r force-pushed the Blacklist_feature branch from ea22051 to a55f88c Compare December 19, 2023 08:02
@vax-r vax-r requested a review from jserv December 19, 2023 08:05
@vax-r vax-r force-pushed the Blacklist_feature branch 2 times, most recently from 2842a47 to adc6373 Compare December 19, 2023 08:19
@vax-r
Copy link
Collaborator Author

vax-r commented Dec 19, 2023

Sorry I've made a mistake on last modification, the unit parameter in netlink_kernel_create shouldn't be MAX_LINKS, MAX_LINKS stands for maximum amount of netlink families , we should choose a netlink family for our netlink socket. In our case I think it's more appropriate to use NETLINK_USERSOCK since we're using netlink for communication between userspace and kernel space.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
vwifi-tool.c Outdated Show resolved Hide resolved
@vax-r vax-r force-pushed the Blacklist_feature branch from b32140f to f84e040 Compare December 25, 2023 16:00
@vax-r
Copy link
Collaborator Author

vax-r commented Dec 25, 2023

@jserv
Request changes are made, including improvements of english writing and modularizing vwifi-tool.c.

@vax-r vax-r requested a review from jserv December 25, 2023 16:02
README.md Outdated Show resolved Hide resolved
@jserv jserv changed the title Support blocklist Implement userspace tool to display driver status and specify blocklist Dec 25, 2023
README.md Show resolved Hide resolved
vwifi-tool.c Outdated Show resolved Hide resolved
vwifi-tool.c Outdated Show resolved Hide resolved
vwifi-tool.c Outdated Show resolved Hide resolved
vwifi-tool.c Show resolved Hide resolved
@jserv
Copy link
Contributor

jserv commented Dec 25, 2023

@jserv Request changes are made, including improvements of english writing and modularizing vwifi-tool.c.

Instead of writing the sentence above (and mentioning me), you can request a code review through the GitHub web interface by selecting the appropriate option. Aim to keep the code review process streamlined and sophisticated, avoiding unnecessary or inefficient language.

@vax-r vax-r force-pushed the Blacklist_feature branch from f84e040 to 295fb4b Compare December 26, 2023 04:15
@vax-r vax-r requested a review from jserv December 26, 2023 04:15
@vax-r vax-r force-pushed the Blacklist_feature branch from 295fb4b to 4e3948f Compare December 26, 2023 04:28
jserv

This comment was marked as outdated.

@vax-r vax-r force-pushed the Blacklist_feature branch from 4e3948f to 1829ede Compare December 27, 2023 01:25
@vax-r vax-r requested a review from jserv December 27, 2023 01:26
Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

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

Read https://cbea.ms/git-commit/ carefully and refine the commit messages.

@vax-r vax-r force-pushed the Blacklist_feature branch from 1829ede to c7fc45b Compare December 27, 2023 05:09
@vax-r
Copy link
Collaborator Author

vax-r commented Dec 27, 2023

I just refined git commit message according to https://cbea.ms/git-commit/
I believe the following requirements are met.

  • Separate subject from body with a blank line
  • Limit the subject line to 50 characters
  • Capitalize the subject line
  • Do not end the subject line with a period
  • Use the imperative mood in the subject line
  • Wrap the body around 72 characters
  • Use the body to explain what and why vs. how

@vax-r vax-r requested a review from jserv December 27, 2023 05:15
@jserv
Copy link
Contributor

jserv commented Dec 27, 2023

I just refined git commit message according to https://cbea.ms/git-commit/ I believe the following requirements are met.
[...]

  • Wrap the body around 72 characters
  • Use the body to explain what and why vs. how

No, you didn't. Check again.

An userspace tool vwifi-tool which can display the status of driver
 and allow users to specify blocklist.

According to sysprog21#48, we want a tool which can configure user-specific
blocklist to filter unwanted packets from certain interfaces.

This tool will show the status of vwifi driver by reading from
`/sys/module/vwifi/initstate`, users can only set blocklist for vwifi
driver when it's loaded.

Users can use vwifi-tool with command line options which is enabled by
 `getopt()` to set or unset user-specific blocklist pair. The blocklist
 will be coppied and sent to the vwifi driver via netlink socket.

Resolves: sysprog21#48
@vax-r vax-r force-pushed the Blacklist_feature branch from c7fc45b to 54b19ec Compare December 27, 2023 12:02
@vax-r
Copy link
Collaborator Author

vax-r commented Dec 27, 2023

I just refined git commit message according to https://cbea.ms/git-commit/ I believe the following requirements are met.
[...]

  • Wrap the body around 72 characters
  • Use the body to explain what and why vs. how

No, you didn't. Check again.

Ok, I've refined it again , each line is at most 72 characters and add more detailed explanation.

@jserv jserv merged commit 7814d59 into sysprog21:main Dec 27, 2023
4 checks passed
@jserv
Copy link
Contributor

jserv commented Dec 27, 2023

Thank @vax-r for contributing. The commit message was amended.

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.

Filtering out certain wifi networks: blocked/allowed-list
2 participants