-
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
base: master
Are you sure you want to change the base?
Coverage #515
Conversation
Can one of the admins verify this patch? |
804729f
to
73e15eb
Compare
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.
Code is pretty much okay.
Can you reorganise your patches, this PR should contain 4 patches:
2 for the coverage, 1 for the brick modification, and one for moving antispoof define to a public header
tests/antispoof/tests.c
Outdated
|
||
/* add NDP_MAX adresses */ | ||
for (int i = 0; i < 150; i++) { | ||
pg_ip_from_str(ip, "2001:db8:2000:aff0::"+i); |
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.
"string" + i
will overflow here, and is UB.
tests/core/test-core.c
Outdated
@@ -44,9 +88,11 @@ static void test_brick_core_simple_lifecycle(void) | |||
brick = pg_brick_new("nop", config, &error); | |||
g_assert(brick); | |||
g_assert(!error); | |||
printf("brick refcount is %ld\n",brick->refcount); |
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.
no don't add printf please, g_assert the refcount is a good idea though
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.
ping ?
tests/core/test-core.c
Outdated
|
||
pg_brick_decref(brick, &error); | ||
g_assert(!error); | ||
printf("brick refcount is %ld\n",brick->refcount); |
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.
same here
src/brick-int.h
Outdated
@@ -207,7 +207,7 @@ struct pg_brick *pg_brick_decref(struct pg_brick *brick, | |||
int pg_brick_reset(struct pg_brick *brick, struct pg_error **errp); | |||
|
|||
/* testing */ | |||
uint32_t pg_brick_links_count_get(const struct pg_brick *brick, | |||
int pg_brick_links_count_get(const struct pg_brick *brick, |
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.
this change brick and had nothing to do with coverage, as sure it should be in a different patch
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.
^ this is still valid
Especially for brick which is use everywhere in packetgraph, change in brick deserver a separate commit
src/brick.c
Outdated
@@ -321,17 +321,17 @@ static uint16_t count_side(const struct pg_brick_side *side, | |||
* @param errp a return pointer for an error message | |||
* @return the total number of link from the brick to the target | |||
*/ | |||
uint32_t pg_brick_links_count_get(const struct pg_brick *brick, | |||
int pg_brick_links_count_get(const struct pg_brick *brick, |
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.
same for this one
include/packetgraph/antispoof.h
Outdated
@@ -21,6 +21,9 @@ | |||
#include <packetgraph/common.h> | |||
#include <packetgraph/errors.h> | |||
|
|||
#define PG_ARP_MAX 100 | |||
#define PG_NPD_MAX 100 |
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.
as this change the brick and not the coverage(and add public define), is should be in another patch
@@ -828,6 +828,11 @@ static void test_brick_core_verify_re_link(void) | |||
test_brick_sanity_check_expected(f, 0, 0); | |||
test_brick_sanity_check_expected(a, 0, 0); | |||
|
|||
pg_brick_unlink(NULL, &e); |
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.
Don't seems related to antispoof, maybe it was for the other patch ?
a58042e
to
ea8960c
Compare
@@ -208,8 +208,8 @@ int pg_brick_reset(struct pg_brick *brick, struct pg_error **errp); | |||
|
|||
/* testing */ | |||
uint32_t pg_brick_links_count_get(const struct pg_brick *brick, | |||
const struct pg_brick *target, |
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
tests/antispoof/test-ndp.c
Outdated
/* pkt3 with Next header : UDP (17) | ||
* | ||
* */ | ||
static unsigned char pkt3[86]; |
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 static is needed
tests/antispoof/tests.c
Outdated
} else { | ||
g_assert(pg_antispoof_arp_add(antispoof, i, &error)); | ||
g_assert(error); | ||
pg_error_free(error); |
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 really think those 3 lines of code could be re-factorise into a macro
(in src/utils/errors.h)
#define PG_CHECK_HAVE_ERROR(error) do {\
g_assert(error);\
pg_error_free(error);\
error = NULL;\
} while (0);
PG_CHECK_HAVE_ERROR is a bad name, but I'm not good at naming
tests/antispoof/tests.c
Outdated
} else { | ||
g_assert(pg_antispoof_arp_add(antispoof, i, &error)); | ||
g_assert(error); | ||
pg_error_free(error); |
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.
so you could use the macro here
@@ -265,8 +316,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 comment
The reason will be displayed to describe this comment to others. Learn more.
you need to call pg_brick_destroy on antispoof again.
tests/antispoof/tests.c
Outdated
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); |
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.
indentation ?
src/brick-int.h
Outdated
@@ -207,7 +207,7 @@ struct pg_brick *pg_brick_decref(struct pg_brick *brick, | |||
int pg_brick_reset(struct pg_brick *brick, struct pg_error **errp); | |||
|
|||
/* testing */ | |||
uint32_t pg_brick_links_count_get(const struct pg_brick *brick, | |||
int pg_brick_links_count_get(const struct pg_brick *brick, |
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.
^ this is still valid
Especially for brick which is use everywhere in packetgraph, change in brick deserver a separate commit
PG_MULTIPOLE); | ||
struct pg_brick_config *config = pg_brick_config_new("mybrick", 2, 2, PG_MULTIPOLE); | ||
struct pg_brick_config *config1 = pg_brick_config_new("mybrick", 2, 2, PG_MONOPOLE); | ||
struct pg_brick_config *config2 = pg_brick_config_new("mybrick", UINT16_MAX, UINT16_MAX, PG_MULTIPOLE); |
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 think config need to be free, it doesn't seems you free the configs
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.
done
tests/core/test-core.c
Outdated
@@ -44,9 +88,11 @@ static void test_brick_core_simple_lifecycle(void) | |||
brick = pg_brick_new("nop", config, &error); | |||
g_assert(brick); | |||
g_assert(!error); | |||
printf("brick refcount is %ld\n",brick->refcount); |
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.
ping ?
middle_brick3 = pg_brick_new("nop", config3, &error); | ||
g_assert(!error); | ||
east_brick3 = pg_brick_new("nop", config3, &error); | ||
g_assert(!error); |
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 you destroy those brick, you you either need to call pg_brick_ptrptr_destroy
at the end of the function or creating the variable using pg_cleanup(pg_brick_ptrptr_destroy)
example:
pg_cleanup(pg_brick_ptrptr_destroy) struct pg_brick_config *config =
pg_brick_config_new("mybrick", 2, 2, PG_MULTIPOLE);
also
pg_cleanup(pg_brick_ptrptr_destroy)
is kind of ugly, so maybe we can create a macro
#define pg_autobrick pg_cleanup(pg_brick_ptrptr_destroy)
bee977d
to
cc9fa12
Compare
Signed-off-by: hanen mizouni <hanen.mizouni@outscale.com>
Signed-off-by: hanen mizouni <hanen.mizouni@outscale.com>
cc9fa12
to
b6d0ef5
Compare
No description provided.