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

tools: labs: Update setup for QEMU image and Linux kernel 4.15 for networking lab #61

Merged
merged 1 commit into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tools/labs/templates/networking/1-2-netfilter/user/test-1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
#

# insert module
insmod filter.ko || exit 1
insmod ../kernel/filter.ko || exit 1

# listen for connections on localhost, port 60000 (run in background)
nc -l -p 60000 &
../../netcat -l -p 60000 &

# wait for netcat to start listening
sleep 1

# connect to localhost, port 60000, starting a connection using local
# port number 600001;
echo "Should show up in filter." | nc 127.0.0.1 60000
echo "Should show up in filter." | ../../netcat -q 2 127.0.0.1 60000

# look for filter message in dmesg output
echo "Check dmesg output."
Expand Down
10 changes: 5 additions & 5 deletions tools/labs/templates/networking/1-2-netfilter/user/test-2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@
#

# insert module
insmod filter.ko || exit 1
insmod ../kernel/filter.ko || exit 1

# set filter IP address to 127.0.0.1
./test 127.0.0.1

# listen for connections on localhost, port 60000 (run in background)
nc -l -p 60000 &
../../netcat -l -p 60000 &

# wait for netcat to start listening
sleep 1

# connect to localhost, port 60000, starting a connection using local
# port number 600001;
echo "Should show up in filter." | nc 127.0.0.1 60000
echo "Should show up in filter." | ../../netcat -q 2 127.0.0.1 60000

# set filter IP address to 127.0.0.2
./test 127.0.0.2

# listen for connections on localhost, port 60000 (run in background)
nc -l -p 60000 &
../../netcat -l -p 60000 &

# wait for netcat to start listening
sleep 1

# connect to localhost, port 60000, starting a connection using local
# port number 600001;
echo "Should NOT show up in filter." | nc 127.0.0.1 60000
echo "Should NOT show up in filter." | ../../netcat -q 2 127.0.0.1 60000

# look for filter message in dmesg output
echo "Check dmesg output."
Expand Down
8 changes: 5 additions & 3 deletions tools/labs/templates/networking/3-4-tcp-sock/tcp_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ int __init my_tcp_sock_init(void)
goto out_release;
}

/* TODO 2/5: create new socket for the accepted connection */
err = sock_create_kern(&init_net, PF_INET, SOCK_STREAM, IPPROTO_TCP, &new_sock);
/* TODO 2/6: create new socket for the accepted connection */
err = sock_create_lite(PF_INET, SOCK_STREAM, IPPROTO_TCP, &new_sock);
if (err < 0) {
printk(LOG_LEVEL "can't create new socket\n");
goto out;
}
new_sock->ops = sock->ops;

/* TODO 2/5: accept a connection */
err = sock->ops->accept(sock, new_sock, 0, true);
Expand All @@ -96,13 +97,14 @@ int __init my_tcp_sock_init(void)
goto out_release_new_sock;
}

/* TODO 2/6: get the address of the peer and print it */
/* TODO 2/7: get the address of the peer and print it */
err = sock->ops->getname(new_sock, (struct sockaddr *) &raddr,
&raddrlen, 1);
if (err < 0) {
printk(LOG_LEVEL "can't find peer name\n");
goto out_release_new_sock;
}
print_sock_address(raddr);

return 0;

Expand Down
2 changes: 1 addition & 1 deletion tools/labs/templates/networking/3-4-tcp-sock/test-4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ netstat -tuan

# connect to localhost, port 60000, starting a connection using local
# port number 600001;
echo "Should connect." | nc 127.0.0.1 60000 -p 60001 &
echo "Should connect." | ../netcat -q 4 127.0.0.1 60000 -p 60001 &

# wait for connection to be established then remove module
# (and close connection)
Expand Down
2 changes: 1 addition & 1 deletion tools/labs/templates/networking/5-udp-sock/test-5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
set -x

# listen for UDP packets on localhost, port 60001 (run in background)
nc -l -u -p 60001 &
../../netcat -l -u -p 60001 &

# get pid of netcat
pid=$!
Expand Down
Binary file added tools/labs/templates/networking/netcat
Binary file not shown.