mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-18 02:39:44 +00:00
Add config set warning if attempting to drop packets on datagram sockets
This commit is contained in:
parent
2e4835d7d6
commit
a6d6175576
@ -989,6 +989,20 @@ int vld_network_interface(const struct cf_om_node *parent, struct config_network
|
||||
cf_warn_missing_node(parent, "file");
|
||||
return result | CFSUB(CFINCOMPATIBLE);
|
||||
}
|
||||
if (nifp->socket_type != SOCK_FILE){
|
||||
int nodei_drop=-1;
|
||||
if (nifp->drop_packets)
|
||||
nodei_drop=cf_om_get_child(parent, "drop_packets", NULL);
|
||||
if (nifp->drop_broadcasts)
|
||||
nodei_drop=cf_om_get_child(parent, "drop_broadcasts", NULL);
|
||||
if (nifp->drop_unicasts)
|
||||
nodei_drop=cf_om_get_child(parent, "drop_unicasts", NULL);
|
||||
if (nodei_drop!=-1){
|
||||
int nodei_socket_type=cf_om_get_child(parent, "socket_type", NULL);
|
||||
cf_warn_incompatible(parent->nodv[nodei_socket_type], parent->nodv[nodei_drop]);
|
||||
return result | CFSUB(CFINCOMPATIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
17
tests/config
17
tests/config
@ -254,10 +254,6 @@ doc_InterfacesModernDummy="Modern 'interfaces.N.file' config option"
|
||||
test_InterfacesModernDummy() {
|
||||
executeOk_servald config set interfaces.0.file dummyname
|
||||
}
|
||||
teardown_InterfacesModernDummy() {
|
||||
tfw_cat $SERVALINSTANCE_PATH/serval.conf
|
||||
teardown
|
||||
}
|
||||
|
||||
doc_InterfacesModernIncompatible="Config options 'interfaces.match' and 'interfaces.file' are incompatible"
|
||||
test_InterfacesModernIncompatible() {
|
||||
@ -270,4 +266,17 @@ test_InterfacesModernIncompatible() {
|
||||
--error-pattern='config file.*loaded despite defects.*incompatible'
|
||||
}
|
||||
|
||||
doc_InterfaceDropDgramIncompatible="Config options 'interfaces.drop_packets' and 'interfaces.socket_type=DGRAM' are incompatible"
|
||||
test_InterfaceDropDgramIncompatible() {
|
||||
executeOk_servald config \
|
||||
set interfaces.0.match eth \
|
||||
set interfaces.0.socket_type dgram
|
||||
execute --stderr --core-backtrace --executable=$servald \
|
||||
config set interfaces.0.drop_packets 10
|
||||
assertExitStatus '==' 2
|
||||
assert_stderr_log \
|
||||
--warn-pattern='"interfaces\.0\..*incompatible' \
|
||||
--error-pattern='config file.*loaded despite defects.*incompatible'
|
||||
}
|
||||
|
||||
runTests "$@"
|
||||
|
Loading…
Reference in New Issue
Block a user