child-sa: Use SA matching mark as SA set mark if the latter is %same

For inbound processing, it can be rather useful to apply the mark to the
packet in the SA, so the associated policy with that mark implicitly matches.
When using %unique as match mark, we don't know the mark beforehand, so
we most likely want to set the mark we match against.
This commit is contained in:
Martin Willi
2018-08-31 12:26:40 +02:00
committed by Tobias Brunner
parent ebd2d3877e
commit 902dc29f7a
6 changed files with 55 additions and 4 deletions
+18
View File
@@ -100,6 +100,24 @@ bool mark_from_string(const char *value, mark_op_t ops, mark_t *mark)
return FALSE;
}
}
else if (strcasepfx(value, "%same"))
{
if (!(ops & MARK_OP_SAME))
{
DBG1(DBG_APP, "unexpected use of %%same mark", value);
return FALSE;
}
endptr = (char*)value + strlen("%same");
if (!*endptr || *endptr == '/')
{
mark->value = MARK_SAME;
}
else
{
DBG1(DBG_APP, "invalid mark value: %s", value);
return FALSE;
}
}
else
{
mark->value = strtoul(value, &endptr, 0);
+3
View File
@@ -215,6 +215,7 @@ struct mark_t {
*/
#define MARK_UNIQUE (0xFFFFFFFF)
#define MARK_UNIQUE_DIR (0xFFFFFFFE)
#define MARK_SAME (0xFFFFFFFF)
#define MARK_IS_UNIQUE(m) ((m) == MARK_UNIQUE || (m) == MARK_UNIQUE_DIR)
/**
@@ -225,6 +226,8 @@ enum mark_op_t {
MARK_OP_NONE = 0,
/** %unique and %unique-dir */
MARK_OP_UNIQUE = (1<<0),
/** %same */
MARK_OP_SAME = (1<<1),
};
/**