diff options
-rw-r--r-- | filter/config.Y | 3 | ||||
-rw-r--r-- | filter/filter.c | 16 |
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"); |