Move Autoconf's macro definitions into config.h.
[openvswitch] / lib / learning-switch.c
index 874e2cbe469202ed5e5e28a70febb62b4c682ae0..b477e7051cbb49bbd527cf81842d51a8a48c4a3e 100644 (file)
@@ -31,6 +31,7 @@
  * derivatives without specific, written prior permission.
  */
 
+#include <config.h>
 #include "learning-switch.h"
 
 #include <errno.h>
@@ -67,6 +68,8 @@ static void queue_tx(struct lswitch *, struct rconn *, struct buffer *);
 static void send_features_request(struct lswitch *, struct rconn *);
 static void process_packet_in(struct lswitch *, struct rconn *,
                               struct ofp_packet_in *);
+static void process_echo_request(struct lswitch *, struct rconn *,
+                                 struct ofp_header *);
 
 /* Creates and returns a new learning switch.
  *
@@ -85,7 +88,7 @@ lswitch_create(struct rconn *rconn, bool learn_macs, int max_idle)
     memset(sw, 0, sizeof *sw);
     sw->max_idle = max_idle;
     sw->datapath_id = 0;
-    sw->last_features_request = 0;
+    sw->last_features_request = time(0) - 1;
     sw->ml = learn_macs ? mac_learning_create() : NULL;
     send_features_request(sw, rconn);
     return sw;
@@ -124,7 +127,9 @@ lswitch_process_packet(struct lswitch *sw, struct rconn *rconn,
         return;
     }
 
-    if (oh->type == OFPT_FEATURES_REPLY) {
+    if (oh->type == OFPT_ECHO_REQUEST) {
+        process_echo_request(sw, rconn, msg->data);
+    } else if (oh->type == OFPT_FEATURES_REPLY) {
         struct ofp_switch_features *osf = msg->data;
         sw->datapath_id = osf->datapath_id;
     } else if (sw->datapath_id == 0) {
@@ -242,3 +247,10 @@ process_packet_in(struct lswitch *sw, struct rconn *rconn,
         queue_tx(sw, rconn, b);
     }
 }
+
+static void
+process_echo_request(struct lswitch *sw, struct rconn *rconn,
+                     struct ofp_header *rq)
+{
+    queue_tx(sw, rconn, make_echo_reply(rq));
+}