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

Allow loopback network interface monitoring. #220

Merged
merged 5 commits into from
Feb 18, 2022

Conversation

ossama-othman
Copy link
Member

Add a new mptcpd_nm_monitor_loopback() function that allows the user to enable monitoring of loopback network interfaces. Monitoring of loopback network interfaces is meant primarily for testing purposes. Mptcpd will retain the previous behavior of only monitoring non-loopback network interfaces by default.

Fixes #208.

Ossama Othman added 2 commits February 17, 2022 10:49
Add a new mptcpd_nm_monitor_loopback() function that allows the user
to enable monitoring of loopback network interfaces.  Monitoring of
loopback network interfaces is meant primarily for testing purposes.
Mptcpd will retain the previous behavior of only monitoring
non-loopback network interfaces by default.
Enable loopback network interface monitoring to allow the
test-network-monitor unit test succeed in cases where non-loopback
interfaces are unavailable, such as in a sandboxed environment.

Fixes #208.
@ossama-othman ossama-othman added this to the Q1-2022 milestone Feb 17, 2022
@ossama-othman ossama-othman self-assigned this Feb 17, 2022
@ossama-othman
Copy link
Member Author

ossama-othman commented Feb 17, 2022

Expected test-network-monitor results (non-loopback IP addresses may vary):

Loopback Network Interface Monitoring Disabled

test-network-monitor.c:check_interface() 
interface
  family: 0
  type:   1
  index:  2
  flags:  0x00011043
  name:   enp3s0
test-network-monitor.c:check_interface()   addrs:
test-network-monitor.c:dump_addr()     192.168.1.48
...
PASS test-network-monitor (exit status: 0)

Loopback Network Interface Monitoring Enabled

test-network-monitor.c:check_interface() 
interface
  family: 0
  type:   772
  index:  1
  flags:  0x00010049
  name:   lo
test-network-monitor.c:check_interface()   addrs:
test-network-monitor.c:dump_addr()     127.0.0.1
test-network-monitor.c:dump_addr()     ::1
test-network-monitor.c:check_interface() 
interface
  family: 0
  type:   1
  index:  2
  flags:  0x00011043
  name:   enp3s0
test-network-monitor.c:check_interface()   addrs:
test-network-monitor.c:dump_addr()     192.168.1.48
...
PASS test-network-monitor (exit status: 0)

Notice the loopback interface and address dump.

@coveralls
Copy link

coveralls commented Feb 17, 2022

Pull Request Test Coverage Report for Build 1860521727

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 11 of 12 (91.67%) changed or added relevant lines in 1 file are covered.
  • 8 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.5%) to 53.734%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/network_monitor.c 11 12 91.67%
Files with Coverage Reduction New Missed Lines %
lib/network_monitor.c 8 43.91%
Totals Coverage Status
Change from base Build 1849124342: 0.5%
Covered Lines: 1072
Relevant Lines: 1995

💛 - Coveralls

@ossama-othman ossama-othman changed the title Allow loopback network interface monitoring, Allow loopback network interface monitoring. Feb 17, 2022
Copy link
Member

@mjmartineau mjmartineau left a comment

Choose a reason for hiding this comment

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

A couple of questions inline

include/mptcpd/network_monitor.h Show resolved Hide resolved
lib/network_monitor.c Show resolved Hide resolved
lib/network_monitor.c Outdated Show resolved Hide resolved
Ossama Othman and others added 3 commits February 17, 2022 13:22
Optimize for the common case by reordering the loopback filtering to
be checked first.

Co-authored-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Copy link
Member

@mjmartineau mjmartineau left a comment

Choose a reason for hiding this comment

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

I'm not set up to test this directly, but looks good to me.

@ossama-othman
Copy link
Member Author

Verified with non-loopback interface down:

$ ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> ...
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> ...

$ sudo ip link set enp3s0 down
$ make check
...

$ sudo ip link set enp3s0 up

$ cat tests/test-network-monitor.log 
test-network-monitor.c:check_interface() 
interface
  family: 0
  type:   772
  index:  1
  flags:  0x00010049
  name:   lo
test-network-monitor.c:check_interface()   addrs:
test-network-monitor.c:dump_addr()     127.0.0.1
test-network-monitor.c:dump_addr()     ::1
PASS test-network-monitor (exit status: 0)

@ossama-othman ossama-othman merged commit a200ef2 into multipath-tcp:master Feb 18, 2022
@ossama-othman ossama-othman deleted the allow-loopback branch February 18, 2022 00:40
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.

test-network-monitor: test-network-monitor.c:290: main: Assertion `data.count > 0' failed.
3 participants