testsuite.at: Workaround for carriage returns on windows.
[sliver-openvswitch.git] / lib / bfd.c
index a8c2294..8bfe385 100644 (file)
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013 Nicira, Inc.
+/* Copyright (c) 2013, 2014 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,7 +30,6 @@
 #include "hmap.h"
 #include "list.h"
 #include "netdev.h"
-#include "netlink.h"
 #include "odp-util.h"
 #include "ofpbuf.h"
 #include "ovs-thread.h"
@@ -470,7 +469,6 @@ bfd_unref(struct bfd *bfd) OVS_EXCLUDED(mutex)
         ovs_mutex_lock(&mutex);
         hmap_remove(all_bfds, &bfd->node);
         netdev_close(bfd->netdev);
-        ovs_refcount_destroy(&bfd->ref_cnt);
         free(bfd->name);
         free(bfd);
         ovs_mutex_unlock(&mutex);
@@ -656,6 +654,11 @@ bfd_process_packet(struct bfd *bfd, const struct flow *flow,
     enum flags flags;
     uint8_t version;
     struct msg *msg;
+    const uint8_t *l7 = ofpbuf_get_udp_payload(p);
+
+    if (!l7) {
+        return; /* No UDP payload. */
+    }
 
     /* This function is designed to follow section RFC 5880 6.8.6 closely. */
 
@@ -670,11 +673,11 @@ bfd_process_packet(struct bfd *bfd, const struct flow *flow,
         goto out;
     }
 
-    msg = ofpbuf_at(p, (uint8_t *)p->l7 - (uint8_t *)p->data, BFD_PACKET_LEN);
+    msg = ofpbuf_at(p, l7 - (uint8_t *)ofpbuf_data(p), BFD_PACKET_LEN);
     if (!msg) {
         VLOG_INFO_RL(&rl, "%s: Received too-short BFD control message (only "
                      "%"PRIdPTR" bytes long, at least %d required).",
-                     bfd->name, (uint8_t *) ofpbuf_tail(p) - (uint8_t *) p->l7,
+                     bfd->name, (uint8_t *) ofpbuf_tail(p) - l7,
                      BFD_PACKET_LEN);
         goto out;
     }
@@ -878,7 +881,7 @@ bfd_forwarding__(struct bfd *bfd) OVS_REQUIRES(mutex)
 static bool
 bfd_lookup_ip(const char *host_name, struct in_addr *addr)
 {
-    if (!inet_aton(host_name, addr)) {
+    if (!inet_pton(AF_INET, host_name, addr)) {
         VLOG_ERR_RL(&rl, "\"%s\" is not a valid IP address", host_name);
         return false;
     }