]> git.proxmox.com Git - ovs.git/commitdiff
Implement basic OpenFlow 1.4 table-mod message.
authorBen Pfaff <blp@nicira.com>
Fri, 9 May 2014 16:11:05 +0000 (09:11 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 14 May 2014 17:31:42 +0000 (10:31 -0700)
Vacancy events and eviction are not yet implemented--see OPENFLOW-1.1+.

Signed-off-by: Ben Pfaff <blp@nicira.com>
include/openflow/openflow-1.4.h
lib/ofp-msgs.h
lib/ofp-util.c
tests/ofp-print.at

index 08f98f95a42a89bcc60901e15045a35c7c6ba67d..d912161a37f3d984361d21674959da6fa069a6cc 100644 (file)
@@ -114,6 +114,47 @@ struct ofp14_port_mod {
 };
 OFP_ASSERT(sizeof(struct ofp14_port_mod) == 24);
 
+/* ## --------------- ## */
+/* ## ofp14_table_mod ## */
+/* ## --------------- ## */
+
+enum ofp14_table_mod_prop_type {
+    OFPTMPT14_EVICTION               = 0x2,    /* Eviction property. */
+    OFPTMPT14_VACANCY                = 0x3,    /* Vacancy property. */
+    OFPTMPT14_EXPERIMENTER           = 0xFFFF, /* Experimenter property. */
+};
+
+enum ofp14_table_mod_prop_eviction_flag {
+    OFPTMPEF14_OTHER           = 1 << 0,     /* Using other factors. */
+    OFPTMPEF14_IMPORTANCE      = 1 << 1,     /* Using flow entry importance. */
+    OFPTMPEF14_LIFETIME        = 1 << 2,     /* Using flow entry lifetime. */
+};
+
+struct ofp14_table_mod_prop_eviction {
+    ovs_be16         type;    /* OFPTMPT14_EVICTION. */
+    ovs_be16         length;  /* Length in bytes of this property. */
+    ovs_be32         flags;   /* Bitmap of OFPTMPEF14_* flags */
+};
+OFP_ASSERT(sizeof(struct ofp14_table_mod_prop_eviction) == 8);
+
+struct ofp14_table_mod_prop_vacancy {
+    ovs_be16         type;   /* OFPTMPT14_VACANCY. */
+    ovs_be16         length; /* Length in bytes of this property. */
+    uint8_t vacancy_down;    /* Vacancy threshold when space decreases (%). */
+    uint8_t vacancy_up;      /* Vacancy threshold when space increases (%). */
+    uint8_t vacancy;      /* Current vacancy (%) - only in ofp14_table_desc. */
+    uint8_t pad[1];          /* Align to 64 bits. */
+};
+OFP_ASSERT(sizeof(struct ofp14_table_mod_prop_vacancy) == 8);
+
+struct ofp14_table_mod {
+    uint8_t table_id;     /* ID of the table, OFPTT_ALL indicates all tables */
+    uint8_t pad[3];         /* Pad to 32 bits */
+    ovs_be32 config;        /* Bitmap of OFPTC_* flags */
+    /* Followed by 0 or more OFPTMPT14_* properties. */
+};
+OFP_ASSERT(sizeof(struct ofp14_table_mod) == 8);
+
 
 /* ## -------------- ## */
 /* ## Miscellaneous. ## */
index 45271b7acf9ff2c5a0499d6b3f0ca1496e307385..def24ce6f98d914f336f8f5121d56db88d6f45c1 100644 (file)
@@ -189,8 +189,10 @@ enum ofpraw {
     /* OFPT 1.4+ (16): struct ofp14_port_mod, uint8_t[8][]. */
     OFPRAW_OFPT14_PORT_MOD,
 
-    /* OFPT 1.1+ (17): struct ofp11_table_mod. */
+    /* OFPT 1.1-1.3 (17): struct ofp11_table_mod. */
     OFPRAW_OFPT11_TABLE_MOD,
+    /* OFPT 1.4+ (17): struct ofp14_table_mod, uint8_t[8][]. */
+    OFPRAW_OFPT14_TABLE_MOD,
 
     /* OFPT 1.0 (18): void. */
     OFPRAW_OFPT10_BARRIER_REQUEST,
@@ -490,7 +492,8 @@ enum ofptype {
     OFPTYPE_PORT_MOD,            /* OFPRAW_OFPT10_PORT_MOD.
                                   * OFPRAW_OFPT11_PORT_MOD.
                                   * OFPRAW_OFPT14_PORT_MOD. */
-    OFPTYPE_TABLE_MOD,           /* OFPRAW_OFPT11_TABLE_MOD. */
+    OFPTYPE_TABLE_MOD,           /* OFPRAW_OFPT11_TABLE_MOD.
+                                  * OFPRAW_OFPT14_TABLE_MOD. */
 
     /* Barrier messages. */
     OFPTYPE_BARRIER_REQUEST,     /* OFPRAW_OFPT10_BARRIER_REQUEST.
index be328db6945591e0c6fc2708588beae9cc321f5f..871d1ec489561674513d17e8a09acacf18e0d8c9 100644 (file)
@@ -4747,6 +4747,13 @@ ofputil_decode_table_mod(const struct ofp_header *oh,
 
         pm->table_id = otm->table_id;
         pm->config = ntohl(otm->config);
+    } else if (raw == OFPRAW_OFPT14_TABLE_MOD) {
+        const struct ofp14_table_mod *otm = ofpbuf_pull(&b, sizeof *otm);
+
+        pm->table_id = otm->table_id;
+        pm->config = ntohl(otm->config);
+        /* We do not understand any properties yet, so we do not bother
+         * parsing them. */
     } else {
         return OFPERR_OFPBRC_BAD_TYPE;
     }
@@ -4781,9 +4788,15 @@ ofputil_encode_table_mod(const struct ofputil_table_mod *pm,
         otm->config = htonl(pm->config);
         break;
     }
-    case OFP14_VERSION:
-        OVS_NOT_REACHED();
+    case OFP14_VERSION: {
+        struct ofp14_table_mod *otm;
+
+        b = ofpraw_alloc(OFPRAW_OFPT14_TABLE_MOD, ofp_version, 0);
+        otm = ofpbuf_put_zeros(b, sizeof *otm);
+        otm->table_id = pm->table_id;
+        otm->config = htonl(pm->config);
         break;
+    }
     default:
         OVS_NOT_REACHED();
     }
index 7d31d5b44db4204da4895550395f8b23f0108af1..5ef959e196e89c161004deb3dad84cd3307bd5b6 100644 (file)
@@ -1067,6 +1067,15 @@ OFPT_TABLE_MOD (OF1.3) (xid=0x2): table_id=2, flow_miss_config=controller
 ])
 AT_CLEANUP
 
+AT_SETUP([OFPT_TABLE_MOD - OF1.4])
+AT_KEYWORDS([ofp-print])
+AT_CHECK([ovs-ofctl ofp-print "\
+05 11 00 10 00 00 00 02 02 00 00 00 00 00 00 00 \
+" 3], [0], [dnl
+OFPT_TABLE_MOD (OF1.4) (xid=0x2): table_id=2, flow_miss_config=controller
+])
+AT_CLEANUP
+
 AT_SETUP([OFPST_DESC request])
 AT_KEYWORDS([ofp-print OFPT_STATS_REQUEST])
 AT_CHECK([ovs-ofctl ofp-print "0110000c0000000100000000"], [0], [dnl