summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2019-03-08 17:48:05 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2019-04-02 00:27:38 +0200
commitd4e5d95e90ac9e5b8eefcdb2aa6baef295dd14cd (patch)
treed6bc14944633ed299518bb3fe4101f658687a80e
parentaf573a252beb379a27da8d3291b358c9911ce627 (diff)
Filter: Allow deletion of bgb_tunnel_encap
-rw-r--r--filter/config.Y3
-rw-r--r--filter/filter.c16
2 files changed, 16 insertions, 3 deletions
diff --git a/filter/config.Y b/filter/config.Y
index 8b5f01e9..04e5758c 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -232,6 +232,9 @@ f_generate_empty(struct f_dynamic_attr dyn)
case EAF_TYPE_LC_SET:
e->aux = T_LCLIST;
break;
+ case EAF_TYPE_TUNNEL_ENCAP:
+ e->aux = T_SET;
+ break;
default:
cf_error("Can't empty that attribute");
}
diff --git a/filter/filter.c b/filter/filter.c
index c2e7a44f..af1165bd 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -629,6 +629,10 @@ calc_tunnel_encap(struct f_tree *t, int *type)
if (t == NULL)
return 0;
+ if (t->from.type == 0) {
+ return 0;
+ }
+
if (t->from.type != T_TLV) {
debug("Not tlv %d\n", t->from.type);
return -1;
@@ -1346,11 +1350,17 @@ interpret(struct f_inst *what)
runtime( "Setting tunnel encap attribute to non-tlv value %d", v1.type );
int type = 0;
int len = calc_tunnel_encap(v1.val.t, &type);
- if (len <= 0)
- runtime( "Empty tunnel encapsulation" );
+ if (len < 0)
+ runtime( "Error tunnel encapsulation" );
+ else if (len == 0) {
+ struct adata *ad = lp_alloc(f_pool, sizeof(struct adata) + len);
+ ad->length = len;
+ l->attrs[0].u.ptr = ad;
+ }
else if (type <= 0 || type > 65535)
runtime( "Invalid tunnel encapsulation type: %d (0 < type <= 65535)", type );
- l->attrs[0].u.ptr = build_tunnel_encap(v1.val.t, type, len);
+ else
+ l->attrs[0].u.ptr = build_tunnel_encap(v1.val.t, type, len);
break;
}
default: bug("Unknown type in e,S");