Skip to content

Commit

Permalink
ACL WIP: Acc SCTP to fun_acl_test
Browse files Browse the repository at this point in the history
allow non-NULL ss2 when adding/deleting ADDRESS ACLs
  • Loading branch information
chrissie-c committed Jul 8, 2021
1 parent 11d6e6a commit 9ebf94b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion libknet/links_acl_ip.c
Expand Up @@ -184,7 +184,7 @@ static struct ip_acl_match_entry *ipcheck_findmatch(struct ip_acl_match_entry **

while (match_entry) {
if ((!memcmp(&match_entry->addr1, ss1, sizeof(struct sockaddr_storage))) &&
((match_entry->type == CHECK_TYPE_ADDRESS && !ss2) ||
((match_entry->type == CHECK_TYPE_ADDRESS) ||
((match_entry->type != CHECK_TYPE_ADDRESS) && ss2 && !memcmp(&match_entry->addr2, ss2, sizeof(struct sockaddr_storage)))) &&
(match_entry->type == type) &&
(match_entry->acceptreject == acceptreject)) {
Expand Down
14 changes: 10 additions & 4 deletions libknet/tests/fun_acl_check.c
Expand Up @@ -134,7 +134,7 @@ static void notify_fn(void *private_data,


#define TESTNODES 2
static int test(void)
static int test(int transport)
{
knet_handle_t knet_h[3];
int logfds[2];
Expand All @@ -157,10 +157,10 @@ static int test(void)
flush_logs(logfds[0], stderr);

// Create the dynamic (receiving) link
FAIL_ON_ERR(dyn_knet_link_set_config(knet_h[1], 2, 0, KNET_TRANSPORT_UDP, 0, AF_INET, 1, &lo0, NULL));
FAIL_ON_ERR(dyn_knet_link_set_config(knet_h[1], 2, 0, transport, 0, AF_INET, 1, &lo0, NULL));

// Connect to the dynamic link
FAIL_ON_ERR(dyn_knet_link_set_config(knet_h[2], 1, 0, KNET_TRANSPORT_UDP, 0, AF_INET, 0, &lo1, &lo0));
FAIL_ON_ERR(dyn_knet_link_set_config(knet_h[2], 1, 0, transport, 0, AF_INET, 0, &lo1, &lo0));

// All the rest of the setup gubbins
FAIL_ON_ERR(knet_handle_enable_sock_notify(knet_h[1], 0, &notify_fn));
Expand Down Expand Up @@ -257,5 +257,11 @@ static int test(void)

int main(int argc, char *argv[])
{
return test();
int res;

res = test(KNET_TRANSPORT_UDP);
if (res == PASS) {
return test(KNET_TRANSPORT_SCTP);
}
return FAIL;
}

0 comments on commit 9ebf94b

Please sign in to comment.