cfm: Support tagged CCM PDUs.
authorEthan Jackson <ethan@nicira.com>
Thu, 3 Nov 2011 20:03:16 +0000 (13:03 -0700)
committerEthan Jackson <ethan@nicira.com>
Thu, 3 Nov 2011 21:01:33 +0000 (14:01 -0700)
This patch also causes eth_compose() to set the l2 and l3 pointers
of the packets which it modifies.

lib/cfm.c
lib/cfm.h
lib/packets.c
vswitchd/bridge.c
vswitchd/vswitch.xml

index 0d79bee..8acbd09 100644 (file)
--- a/lib/cfm.c
+++ b/lib/cfm.c
@@ -93,6 +93,7 @@ struct cfm {
     uint32_t seq;          /* The sequence number of our last CCM. */
     uint8_t ccm_interval;  /* The CCM transmission interval. */
     int ccm_interval_ms;   /* 'ccm_interval' in milliseconds. */
+    uint16_t ccm_vlan;     /* Vlan tag of CCM PDUs. */
     uint8_t maid[CCM_MAID_LEN]; /* The MAID of this CFM. */
 
     struct timer tx_timer;    /* Send CCM when expired. */
@@ -345,8 +346,13 @@ cfm_compose_ccm(struct cfm *cfm, struct ofpbuf *packet,
     struct ccm *ccm;
 
     timer_set_duration(&cfm->tx_timer, cfm->ccm_interval_ms);
-    ccm = eth_compose(packet, cfm_ccm_addr(cfm), eth_src, ETH_TYPE_CFM,
-                      sizeof *ccm);
+    eth_compose(packet, cfm_ccm_addr(cfm), eth_src, ETH_TYPE_CFM, sizeof *ccm);
+
+    if (cfm->ccm_vlan) {
+        eth_push_vlan(packet, htons(cfm->ccm_vlan));
+    }
+
+    ccm = packet->l3;
     ccm->mdlevel_version = 0;
     ccm->opcode = CCM_OPCODE;
     ccm->tlv_offset = 70;
@@ -400,6 +406,7 @@ cfm_configure(struct cfm *cfm, const struct cfm_settings *s)
     interval = ms_to_ccm_interval(s->interval);
     interval_ms = ccm_interval_to_ms(interval);
 
+    cfm->ccm_vlan = s->ccm_vlan & VLAN_VID_MASK;
     if (cfm->extended && interval_ms != s->interval) {
         interval = 0;
         interval_ms = MIN(s->interval, UINT16_MAX);
index 1c46ffa..334b80c 100644 (file)
--- a/lib/cfm.h
+++ b/lib/cfm.h
@@ -29,6 +29,7 @@ struct cfm_settings {
     int interval;               /* The requested transmission interval. */
     bool extended;              /* Run in extended mode. */
     bool opup;                  /* Operational State. */
+    uint16_t ccm_vlan;          /* CCM Vlan tag. Zero if none. */
 };
 
 void cfm_init(void);
index b704276..03f92e3 100644 (file)
@@ -259,7 +259,8 @@ ipv6_is_cidr(const struct in6_addr *netmask)
 /* Populates 'b' with an Ethernet II packet headed with the given 'eth_dst',
  * 'eth_src' and 'eth_type' parameters.  A payload of 'size' bytes is allocated
  * in 'b' and returned.  This payload may be populated with appropriate
- * information by the caller.
+ * information by the caller.  Sets 'b''s 'l2' and 'l3' pointers to the
+ * Ethernet header and payload respectively.
  *
  * The returned packet has enough headroom to insert an 802.1Q VLAN header if
  * desired. */
@@ -282,6 +283,9 @@ eth_compose(struct ofpbuf *b, const uint8_t eth_dst[ETH_ADDR_LEN],
     memcpy(eth->eth_src, eth_src, ETH_ADDR_LEN);
     eth->eth_type = htons(eth_type);
 
+    b->l2 = eth;
+    b->l3 = data;
+
     return data;
 }
 
index 09696d5..5100b78 100644 (file)
@@ -3005,6 +3005,8 @@ iface_configure_cfm(struct iface *iface)
     s.mpid = *cfg->cfm_mpid;
     s.interval = atoi(get_interface_other_config(iface->cfg, "cfm_interval",
                                                  "0"));
+    s.ccm_vlan = atoi(get_interface_other_config(iface->cfg, "cfm_ccm_vlan",
+                                                 "0"));
     if (s.interval <= 0) {
         s.interval = 1000;
     }
index bcb6b6f..80d9cdc 100644 (file)
         OpenFlow action. This setting is ignored when CFM is not in extended
         mode.  Defaults to <code>up</code>.
       </column>
+
+      <column name="other_config" key="cfm_ccm_vlan"
+        type='{"type": "integer", "minInteger": 1, "maxInteger": 4095}'>
+        When set, the CFM module will apply a VLAN tag to all CCMs it generates
+        with the given value.
+      </column>
+
     </group>
 
     <group title="Bonding Configuration">