2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

Support matching and modifying IP TTL.

Add support matching the IPv4 TTL and IPv6 hop limit fields.  This
commit also adds support for modifying the IPv4 TTL.  Modifying the IPv6
hop limit isn't currently supported, since we don't support modifying
IPv6 headers.

We will likely want to change the user-space interface, since basic
matching and setting the TTL are not generally useful.  We will probably
want the ability to match on extraordinary events (such as TTL of 0 or 1)
and a decrement action.

Feature #8024

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
This commit is contained in:
Justin Pettit
2011-11-05 15:48:12 -07:00
parent 530180fd5a
commit a61680c6d1
26 changed files with 208 additions and 72 deletions

View File

@@ -333,6 +333,13 @@ cls_rule_set_nw_ecn(struct cls_rule *rule, uint8_t nw_ecn)
rule->flow.tos |= nw_ecn & IP_ECN_MASK;
}
void
cls_rule_set_nw_ttl(struct cls_rule *rule, uint8_t nw_ttl)
{
rule->wc.wildcards &= ~FWW_NW_TTL;
rule->flow.nw_ttl = nw_ttl;
}
void
cls_rule_set_frag(struct cls_rule *rule, uint8_t frag)
{
@@ -480,7 +487,7 @@ cls_rule_format(const struct cls_rule *rule, struct ds *s)
int i;
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 5);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 6);
if (rule->priority != OFP_DEFAULT_PRIORITY) {
ds_put_format(s, "priority=%d,", rule->priority);
@@ -631,6 +638,9 @@ cls_rule_format(const struct cls_rule *rule, struct ds *s)
if (wc->tos_mask & IP_ECN_MASK) {
ds_put_format(s, "nw_ecn=%"PRIu8",", f->tos & IP_ECN_MASK);
}
if (!(w & FWW_NW_TTL)) {
ds_put_format(s, "nw_ttl=%"PRIu8",", f->nw_ttl);
}
switch (wc->frag_mask) {
case FLOW_FRAG_ANY | FLOW_FRAG_LATER:
ds_put_format(s, "frag=%s,",
@@ -1177,7 +1187,7 @@ flow_equal_except(const struct flow *a, const struct flow *b,
const flow_wildcards_t wc = wildcards->wildcards;
int i;
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 5);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 6);
for (i = 0; i < FLOW_N_REGS; i++) {
if ((a->regs[i] ^ b->regs[i]) & wildcards->reg_masks[i]) {
@@ -1204,6 +1214,7 @@ flow_equal_except(const struct flow *a, const struct flow *b,
&& (wc & FWW_ETH_MCAST
|| !((a->dl_dst[0] ^ b->dl_dst[0]) & 0x01))
&& (wc & FWW_NW_PROTO || a->nw_proto == b->nw_proto)
&& (wc & FWW_NW_TTL || a->nw_ttl == b->nw_ttl)
&& !((a->tos ^ b->tos) & wildcards->tos_mask)
&& !((a->frag ^ b->frag) & wildcards->frag_mask)
&& (wc & FWW_ARP_SHA || eth_addr_equals(a->arp_sha, b->arp_sha))