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:
committed by
Tobias Brunner
parent
ebd2d3877e
commit
902dc29f7a
@@ -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);
|
||||
|
||||
@@ -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),
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -916,6 +916,12 @@ static struct {
|
||||
{ 0, 0 }},
|
||||
{"%unique-foo/0xffffffff", FALSE, MARK_OP_UNIQUE,
|
||||
{ 0, 0 }},
|
||||
{"%same", TRUE, MARK_OP_SAME,
|
||||
{ MARK_SAME, 0xffffffff }},
|
||||
{"%same/0x0000ffff", TRUE, MARK_OP_SAME,
|
||||
{ MARK_SAME, 0x0000ffff }},
|
||||
{"%%same", FALSE, MARK_OP_NONE,
|
||||
{ 0, 0 }},
|
||||
};
|
||||
|
||||
START_TEST(test_mark_from_string)
|
||||
|
||||
Reference in New Issue
Block a user