-
Notifications
You must be signed in to change notification settings - Fork 28
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
Coverage #515
Open
outscale-hmi
wants to merge
2
commits into
outscale:master
Choose a base branch
from
outscale-hmi:coverage
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Coverage #515
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
#include "fail.h" | ||
#include "utils/mac.h" | ||
#include "utils/ip.h" | ||
#include "utils/errors.h" | ||
|
||
static struct rte_mbuf *build_packet(const unsigned char *data, size_t len) | ||
{ | ||
|
@@ -253,10 +254,57 @@ static void test_antispoof_generic(const unsigned char **pkts, | |
pg_error_free(error); | ||
error = NULL; | ||
|
||
/* re-add other IP and original IP, should pass */ | ||
g_assert(!pg_antispoof_arp_del(antispoof, 42, &error)); | ||
g_assert(!pg_antispoof_arp_del(antispoof, 51, &error)); | ||
g_assert(!pg_antispoof_arp_add(antispoof, 42, &error)); | ||
g_assert(!pg_antispoof_arp_add(antispoof, 51, &error)); | ||
g_assert(!pg_antispoof_arp_add(antispoof, inside_ip, &error)); | ||
g_assert(!error); | ||
REPLAY(1); | ||
|
||
/* remove IP, should not pass */ | ||
pg_antispoof_arp_del_all(antispoof); | ||
REPLAY(0); | ||
|
||
/* add ARP_MAX */ | ||
for (int i = 0; i <= 150; i++) { | ||
if (i < PG_ARP_MAX) { | ||
g_assert(!pg_antispoof_arp_add(antispoof, i, &error)); | ||
g_assert(!error); | ||
} else { | ||
g_assert(pg_antispoof_arp_add(antispoof, i, &error)); | ||
PG_ERROR_EXISTS(error); | ||
} | ||
} | ||
|
||
/* remove IP, should not pass */ | ||
pg_antispoof_arp_del_all(antispoof); | ||
REPLAY(0); | ||
|
||
/* disable arp antispoof, should pass */ | ||
pg_antispoof_arp_disable(antispoof); | ||
REPLAY(1); | ||
|
||
/* add ARP_MAX */ | ||
for (int i = 0; i <= 150; i++) { | ||
if (i < PG_ARP_MAX) { | ||
g_assert(!pg_antispoof_arp_add(antispoof, i, &error)); | ||
g_assert(!error); | ||
} else { | ||
g_assert(pg_antispoof_arp_add(antispoof, i, &error)); | ||
PG_ERROR_EXISTS(error); | ||
} | ||
} | ||
|
||
/* remove IP, should pass */ | ||
pg_antispoof_arp_del_all(antispoof); | ||
REPLAY(1); | ||
|
||
/* disable arp antispoof, should pass */ | ||
pg_antispoof_arp_disable(antispoof); | ||
REPLAY(1); | ||
|
||
/* enable arp antispoof again, should re-block */ | ||
pg_antispoof_arp_enable(antispoof); | ||
REPLAY(0); | ||
|
@@ -265,8 +313,7 @@ static void test_antispoof_generic(const unsigned char **pkts, | |
pg_brick_unlink(antispoof, &error); | ||
g_assert(!error); | ||
pg_brick_destroy(antispoof); | ||
antispoof = pg_antispoof_new("antispoof", PG_WEST_SIDE, | ||
&inside_mac, &error); | ||
antispoof = pg_antispoof_new("antispoof", PG_WEST_SIDE, &inside_mac, &error); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you need to call pg_brick_destroy on antispoof again. |
||
pg_antispoof_arp_enable(antispoof); | ||
g_assert(!pg_antispoof_arp_add(antispoof, inside_ip, &error)); | ||
g_assert(!error); | ||
|
@@ -275,6 +322,7 @@ static void test_antispoof_generic(const unsigned char **pkts, | |
pg_brick_link(antispoof, col_east, &error); | ||
g_assert(!error); | ||
REPLAY(1); | ||
pg_brick_destroy(antispoof); | ||
#undef REPLAY | ||
|
||
pg_brick_destroy(gen_west); | ||
|
@@ -437,8 +485,8 @@ static void test_antispoof_empty_burst(void) | |
g_free(pkts); | ||
} | ||
|
||
static int test_antispoof_filter(struct pg_brick *antispoof, | ||
struct rte_mbuf *packet) | ||
static int test_antispoof_filter(struct pg_brick *antispoof, | ||
struct rte_mbuf *packet) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't seems an useful change |
||
{ | ||
struct pg_brick *gen_west; | ||
struct pg_brick *col_east; | ||
|
@@ -521,6 +569,30 @@ static void test_antispoof_ndp(void) | |
pg_antispoof_ndp_enable(antispoof); | ||
pg_antispoof_ndp_del_all(antispoof); | ||
|
||
/* add NDP_MAX adresses */ | ||
for (int i = 0; i < 150; i++) { | ||
pg_autofree char *c = g_strdup_printf("2001:db8:2000:aff0::%d",i); | ||
pg_ip_from_str(ip, c); | ||
if (i < PG_NPD_MAX) { | ||
pg_antispoof_ndp_add(antispoof, ip, &error); | ||
g_assert(!error); | ||
} else { | ||
pg_antispoof_ndp_add(antispoof, ip, &error); | ||
PG_ERROR_EXISTS(error); | ||
} | ||
} | ||
|
||
/* remove all adresses */ | ||
pg_antispoof_ndp_del_all(antispoof); | ||
|
||
/* add several bad addresses */ | ||
pg_ip_from_str(ip, "2001:db8:2000:aff0::42"); | ||
pg_antispoof_ndp_add(antispoof, ip, &error); | ||
g_assert(!error); | ||
|
||
/* remove all addresses */ | ||
pg_antispoof_ndp_del(antispoof,ip,&error); | ||
|
||
/* legit packet */ | ||
packet = build_packet(pkt0, 86); | ||
g_assert(test_antispoof_filter(antispoof, packet) == 0); | ||
|
@@ -538,10 +610,24 @@ static void test_antispoof_ndp(void) | |
pg_ip_from_str(ip, "2001:db8:2000:aff0::42"); | ||
pg_antispoof_ndp_add(antispoof, ip, &error); | ||
g_assert(!error); | ||
pg_ip_from_str(ip, "2001:db8:2000:aff0::43"); | ||
pg_ip_from_str(ip, "0"); | ||
pg_antispoof_ndp_add(antispoof, ip, &error); | ||
g_assert(!error); | ||
|
||
/* remove adresse */ | ||
g_assert(pg_antispoof_ndp_del(antispoof,ip,&error) == 0); | ||
g_assert(!error); | ||
|
||
/* legit packet with next header :UDP */ | ||
packet = build_packet(pkt3, 86); | ||
g_assert(test_antispoof_filter(antispoof, packet) != 0); | ||
pg_packets_free(&packet, pg_mask_firsts(1)); | ||
|
||
/* legit packet with type Redirect Message */ | ||
packet = build_packet(pkt4, 86); | ||
g_assert(test_antispoof_filter(antispoof, packet) == 0); | ||
pg_packets_free(&packet, pg_mask_firsts(1)); | ||
|
||
/* legit packet */ | ||
packet = build_packet(pkt0, 86); | ||
g_assert(test_antispoof_filter(antispoof, packet) == 0); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this change is useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is just to remove the extra white space