Skip to content

Commit

Permalink
Add more improvements inspired by the #232 review
Browse files Browse the repository at this point in the history
Includes

- A fix to the 6791 pool: was always using host addresses,
  regardless of whether the pool had elements or not.
- More graybox improvements.
- More comments.
  • Loading branch information
ydahhrk committed Dec 2, 2016
1 parent a6f6f60 commit d62b2ff
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 51 deletions.
4 changes: 2 additions & 2 deletions include/nat64/mod/common/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* (bad checksums, bogus addresses, etc) and some failed memory allocations
* (because the kernel already prints those).
*/
#define log_debug(text, ...) pr_debug(text "\n", ##__VA_ARGS__)
#define log_debug(text, ...) pr_debug("%s: " text "\n", xlat_get_name(), ##__VA_ARGS__)
/**
* Responses to events triggered by the user, which might not show signs of life
* elsehow.
*/
#define log_info(text, ...) pr_info(text "\n", ##__VA_ARGS__)
#define log_info(text, ...) pr_info("%s: " text "\n", xlat_get_name(), ##__VA_ARGS__)
/**
* "I'm not going to translate this because the config's not right."
* These rate limit themselves so the log doesn't get too flooded.
Expand Down
6 changes: 4 additions & 2 deletions mod/common/rfc6145/4to6.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ verdict ttp46_create_skb(struct xlation *state)
* The subpayload might get truncated to maximize delivery probability.
*/
l3_hdr_len = sizeof(struct ipv6hdr);
if (will_need_frag_hdr(pkt_ip4_hdr(in)))
if (will_need_frag_hdr(pkt_ip4_hdr(in))) {
l3_hdr_len += sizeof(struct frag_hdr);
else
} else {
/* The kernel might want to fragment this so leave room.*/
reserve += sizeof(struct frag_hdr);
}

total_len = l3_hdr_len + pkt_l3payload_len(in);
if (is_first_frag4(pkt_ip4_hdr(in)) && pkt_is_icmp4_error(in)) {
Expand Down
2 changes: 1 addition & 1 deletion mod/stateless/rfc6791.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static int get_rfc6791_address(struct xlation *state, unsigned int count,
done = pool_foreach(state->jool.siit.pool6791, find_nth_addr,
&args, NULL);
if (done)
return done;
return 0;

if (args.flushed)
return -ESRCH;
Expand Down
72 changes: 36 additions & 36 deletions test/graybox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,77 +31,75 @@ See the content of `run.sh` for more versatility.

Please [report](https://github.com/NICMx/Jool/issues) any errors or queued packets you find. Please include your distro, kernel version (`uname -r`) and the tail of `dmesg` (after the "SIIT/NAT64 Jool vX.Y.Z.W module inserted" caption).

That's everything most users need to know. See below if you want to add tests to the suite.
That's everything you need to know if you just want to run the tests. See below if you'd like to add tests to the suite.

## Preparing tests

This is what you need to know:

Adding tests to the suite right away is cumbersome; you don't want to run the entire suite when you're testing your *test*. To speed things up, you can run improvised standalone packet exchanges with the suite's translators by interacting with the following scripts (attached):
Adding tests to the suite right away is cumbersome; you don't want to run the entire thing when you're just testing your *test*. To speed things up, you can run improvised standalone packet exchanges with the suite's translators by interacting with the following scripts (in the `test-suite` folder):

test-suite/namespace-create.sh
namespace-create.sh
Creates a network namespace where the translator will be
enclosed and the relevant virtual interfaces.
test-suite/namespace-destroy.sh
Cleans up whatever namespace-crete.sh did.
test-suite/network-create.sh <translator>
See the output of `ip netns` and `ip link` to take a peek
to the results.
namespace-destroy.sh
Reverts whatever namespace-create.sh did.
network-create.sh <translator>
Prepares the test network for the relevant translator.
<translator> can be either "siit" or "nat64".
test-suite/network-destroy.sh <translator>
Cleans up whatever network-crete.sh did.
See the output of `ip addr` to take a peek to the
results.
network-destroy.sh <translator>
Reverts whatever network-create.sh did.

So, for example, to prepare an environment to send some improvised packets to the SIIT translator, run

```bash
test-suite/namespace-create.sh
test-suite/network-create.sh siit
cd test-suite
sudo ./namespace-create.sh
sudo ./network-create.sh siit
cd ..
```

A description of the network we just created can be found in `test-suite/siit network.txt`. (TODO we need a NAT64 version too.)

You can run `ip address` here to see your channels to your "improvised" translator.
A description of the network you just created can be found in `test-suite/siit network.txt`. (TODO we need a NAT64 version too.) See `ip address` too.

Then send some packets and see how Jool behaves (via `tcpdump`, `dmesg` and stuff):
Then send some test packets. Evaluate results via tools such as `dmesg` (if you enabled [debug](https://github.com/NICMx/Jool/wiki/Jool's-Compilation-Options#-ddebug)) and `tcpdump`. Graybox expects test packets to be contained verbatim (from layer 3 header onwards) in a file. See examples in `test-suite/client/siit/manual`.

```bash
usr/graybox send some-packet-1.pkt
usr/graybox send some-packet-2.pkt
usr/graybox send some-packet-3.pkt
usr/graybox send /path/to/some-packet-1.pkt
usr/graybox send /path/to/some-packet-2.pkt
usr/graybox send /path/to/some-packet-3.pkt
```

See `man usr/graybox.7` for more documentation on what `usr/graybox` can do.

Finally, when you're done, issue the following commands to clean up:

```bash
test-suite/network-destroy.sh siit
test-suite/namespace-destroy.sh
cd test-suite
sudo ./network-destroy.sh siit
sudo ./namespace-destroy.sh
cd ..
```

## Adding improvised tests to the suite

(TODO now that I added the previous section, this is kind of obsolete and should become "how to add your improvised test to the suite.")
## Adding your "improvised" test to the suite

You need to provide:
For every test, you need to provide:

- A "test" packet. (A packet that is sent to the translator.)
- A "test" packet. (A packet that is sent to the translator. It's the one you generated during the previous step.)
- An "expected" packet. (The packet that we expect the translator to turn the "test" packet into.)

The framework expects each packet to be found verbatim (layer 3 header, layer 4 header, payload) in a dedicated file. See examples in `test-suite/client/siit/manual`.

Assuming that there is a translator available, and the packets' addresses will be routed towards and back from it, a standalone test can be pulled off as follows:
Test "expected" by doing something like (assuming the namespace and the network are set)

```bash
# Start graybox.
insmod mod/graybox.ko
# Tell graybox to "expect" packet foo.pkt
usr/graybox expect add foo.pkt
# Tell graybox to send "test" packet bar.pkt
usr/graybox send bar.pkt
usr/graybox expect add /path/to/foo.pkt
# Ask graybox to send "test" packet bar.pkt
usr/graybox send /path/to/bar.pkt
# Wait. Jool translates bar.pkt and graybox validates the response.
# Hopefully this should happen in less than a tenth of a second.
# I wish I had a more bulletproff and less wasteful way to do this.
# Maybe later.
# This is only for scripts. If you're typing this, you obviously don't need this
# unless you can type faster than the kernel can send packets.
sleep 0.1
Expand All @@ -111,10 +109,12 @@ sleep 0.1
usr/graybox expect flush
# Print the results.
usr/graybox stats display
# Stop graybox.
rmmod graybox
```

Place both the expected and test packets in `test-suite/client/<translator>/manual` and register them in `test-suite/client/<translator>/manual.sh`.

Test the full suite and you're done. Might want to commit and upload your work to the repository.

## Some notes

- I don't know if the graybox kernel module is a very elegant way to do this. Perhaps raw sockets would get the job done just fine.
Expand Down
19 changes: 9 additions & 10 deletions test/graybox/test-suite/client/siit/manual.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
#!/bin/bash


GRAYBOX=`dirname $0`/../../../usr/graybox


function test-single {
graybox expect add $2-nofrag.pkt $3
graybox send $1-nofrag.pkt
$GRAYBOX expect add $2-expected.pkt $3
$GRAYBOX send $1-test.pkt
sleep 0.1
graybox expect flush
$GRAYBOX expect flush
}


# test-frags 4-udp-csumok-nodf 6-udp-csumok-nodf
# test-frags 4-udp-csumfail-nodf 6-udp-csumfail-nodf

test-single manual/igmp6-sender manual/igmp4-receiver 4,5,10,11
test-single manual/igmp4-sender manual/igmp6-receiver
test-single manual/igmp64 4,5,10,11
test-single manual/igmp46
test-single manual/6791 4,5,10,11,32,33,38,39

#NAT64/tests/graybox/usr/graybox -sa --pkt manual/error-addresses-test.pkt
#NAT64/tests/graybox/usr/graybox -sa --pkt manual/loop.pkt

graybox stats display
graybox stats flush
Expand Down
Binary file not shown.
Binary file removed test/graybox/test-suite/client/siit/manual/6791.pkt
Binary file not shown.
Binary file removed test/graybox/test-suite/client/siit/manual/loop.pkt
Binary file not shown.

0 comments on commit d62b2ff

Please sign in to comment.