X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fnetdev-vport.c;h=f6dbd03edd05443f08ce7e4c9b959621082c78a1;hb=dfbf7f354416264a0b84b09bf882ac0932e78c8b;hp=06ec8fbedb2a3723f246bb00024d2b7dffd2f88b;hpb=ee9bed06cd2794ced29190b6c6539993159d76f5;p=openvswitch diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c index 06ec8fbe..f6dbd03e 100644 --- a/lib/netdev-vport.c +++ b/lib/netdev-vport.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -38,12 +39,12 @@ #include "netlink-notifier.h" #include "netlink-socket.h" #include "ofpbuf.h" -#include "openvswitch/datapath-protocol.h" #include "openvswitch/tunnel.h" #include "packets.h" #include "route-table.h" #include "shash.h" #include "socket-util.h" +#include "unaligned.h" #include "vlog.h" VLOG_DEFINE_THIS_MODULE(netdev_vport); @@ -361,22 +362,21 @@ netdev_vport_get_etheraddr(const struct netdev *netdev, return error; } -#define COPY_OVS_STATS \ - dst->rx_packets = src->rx_packets; \ - dst->tx_packets = src->tx_packets; \ - dst->rx_bytes = src->rx_bytes; \ - dst->tx_bytes = src->tx_bytes; \ - dst->rx_errors = src->rx_errors; \ - dst->tx_errors = src->tx_errors; \ - dst->rx_dropped = src->rx_dropped; \ - dst->tx_dropped = src->tx_dropped; - -/* Copies 'src' into 'dst', performing format conversion in the process. */ +/* Copies 'src' into 'dst', performing format conversion in the process. + * + * 'src' is allowed to be misaligned. */ static void netdev_stats_from_ovs_vport_stats(struct netdev_stats *dst, const struct ovs_vport_stats *src) { - COPY_OVS_STATS + dst->rx_packets = get_unaligned_u64(&src->rx_packets); + dst->tx_packets = get_unaligned_u64(&src->tx_packets); + dst->rx_bytes = get_unaligned_u64(&src->rx_bytes); + dst->tx_bytes = get_unaligned_u64(&src->tx_bytes); + dst->rx_errors = get_unaligned_u64(&src->rx_errors); + dst->tx_errors = get_unaligned_u64(&src->tx_errors); + dst->rx_dropped = get_unaligned_u64(&src->rx_dropped); + dst->tx_dropped = get_unaligned_u64(&src->tx_dropped); dst->multicast = 0; dst->collisions = 0; dst->rx_length_errors = 0; @@ -397,7 +397,14 @@ static void netdev_stats_to_ovs_vport_stats(struct ovs_vport_stats *dst, const struct netdev_stats *src) { - COPY_OVS_STATS + dst->rx_packets = src->rx_packets; + dst->tx_packets = src->tx_packets; + dst->rx_bytes = src->rx_bytes; + dst->tx_bytes = src->tx_bytes; + dst->rx_errors = src->rx_errors; + dst->tx_errors = src->tx_errors; + dst->rx_dropped = src->rx_dropped; + dst->tx_dropped = src->tx_dropped; } int @@ -571,6 +578,7 @@ parse_tunnel_config(const char *name, const char *type, struct shash_node *node; bool ipsec_mech_set = false; ovs_be32 daddr = htonl(0); + ovs_be32 saddr = htonl(0); uint32_t flags; flags = TNL_F_DF_DEFAULT | TNL_F_PMTUD | TNL_F_HDR_CACHE; @@ -596,8 +604,7 @@ parse_tunnel_config(const char *name, const char *type, if (lookup_ip(node->data, &in_addr)) { VLOG_WARN("%s: bad %s 'local_ip'", name, type); } else { - nl_msg_put_be32(options, OVS_TUNNEL_ATTR_SRC_IPV4, - in_addr.s_addr); + saddr = in_addr.s_addr; } } else if (!strcmp(node->name, "tos")) { if (!strcmp(node->data, "inherit")) { @@ -700,6 +707,14 @@ parse_tunnel_config(const char *name, const char *type, } nl_msg_put_be32(options, OVS_TUNNEL_ATTR_DST_IPV4, daddr); + if (saddr) { + if (ip_is_multicast(daddr)) { + VLOG_WARN("%s: remote_ip is multicast, ignoring local_ip", name); + } else { + nl_msg_put_be32(options, OVS_TUNNEL_ATTR_SRC_IPV4, saddr); + } + } + nl_msg_put_u32(options, OVS_TUNNEL_ATTR_FLAGS, flags); return 0; @@ -899,6 +914,7 @@ unparse_patch_config(const char *name OVS_UNUSED, const char *type OVS_UNUSED, NULL, /* set_mtu */ \ NULL, /* get_ifindex */ \ NULL, /* get_carrier */ \ + NULL, /* get_carrier_resets */ \ NULL, /* get_miimon */ \ netdev_vport_get_stats, \ netdev_vport_set_stats, \