#include "daemon.h"
#include "dirs.h"
#include "dpif.h"
+#include "dp-packet.h"
#include "dynamic-string.h"
#include "flow.h"
#include "hash.h"
#include "list.h"
#include "netdev-provider.h"
#include "odp-netlink.h"
-#include "ofpbuf.h"
+#include "dp-packet.h"
#include "ovs-router.h"
#include "packets.h"
-#include "packet-dpif.h"
#include "poll-loop.h"
#include "route-table.h"
#include "shash.h"
#include "socket-util.h"
-#include "vlog.h"
+#include "openvswitch/vlog.h"
#include "unaligned.h"
#include "unixctl.h"
#include "util.h"
struct netdev_tunnel_config tnl_cfg;
struct smap_node *node;
- has_csum = strstr(type, "gre");
+ has_csum = strstr(type, "gre") || strstr(type, "geneve") ||
+ strstr(type, "vxlan");
ipsec_mech_set = false;
memset(&tnl_cfg, 0, sizeof tnl_cfg);
!strcmp(node->key, "in_key") ||
!strcmp(node->key, "out_key")) {
/* Handled separately below. */
+ } else if (!strcmp(node->key, "exts")) {
+ char *str = xstrdup(node->value);
+ char *ext, *save_ptr = NULL;
+
+ tnl_cfg.exts = 0;
+
+ ext = strtok_r(str, ",", &save_ptr);
+ while (ext) {
+ if (!strcmp(type, "vxlan") && !strcmp(ext, "gbp")) {
+ tnl_cfg.exts |= (1 << OVS_VXLAN_EXT_GBP);
+ } else {
+ VLOG_WARN("%s: unknown extension '%s'", name, ext);
+ }
+
+ ext = strtok_r(NULL, ",", &save_ptr);
+ }
+
+ free(str);
} else {
VLOG_WARN("%s: unknown %s argument '%s'", name, type, node->key);
}
&tnl_cfg.out_key_flow);
ovs_mutex_lock(&dev->mutex);
- dev->tnl_cfg = tnl_cfg;
- tunnel_check_status_change__(dev);
- netdev_change_seq_changed(dev_);
+ if (memcmp(&dev->tnl_cfg, &tnl_cfg, sizeof tnl_cfg)) {
+ dev->tnl_cfg = tnl_cfg;
+ tunnel_check_status_change__(dev);
+ netdev_change_seq_changed(dev_);
+ }
ovs_mutex_unlock(&dev->mutex);
return 0;
}
ovs_mutex_lock(&dev->mutex);
- free(dev->peer);
- dev->peer = xstrdup(peer);
- netdev_change_seq_changed(dev_);
+ if (!dev->peer || strcmp(dev->peer, peer)) {
+ free(dev->peer);
+ dev->peer = xstrdup(peer);
+ netdev_change_seq_changed(dev_);
+ }
ovs_mutex_unlock(&dev->mutex);
return 0;
}
static void *
-ip_extract_tnl_md(struct ofpbuf *packet, struct flow_tnl *tnl)
+ip_extract_tnl_md(struct dp_packet *packet, struct flow_tnl *tnl)
{
struct ip_header *nh;
void *l4;
- nh = ofpbuf_l3(packet);
- l4 = ofpbuf_l4(packet);
+ nh = dp_packet_l3(packet);
+ l4 = dp_packet_l4(packet);
if (!nh || !l4) {
return NULL;
*
* Return pointer to the L4 header added to 'packet'. */
static void *
-push_ip_header(struct ofpbuf *packet,
+push_ip_header(struct dp_packet *packet,
const void *header, int size, int *ip_tot_size)
{
struct eth_header *eth;
struct ip_header *ip;
- eth = ofpbuf_push_uninit(packet, size);
- *ip_tot_size = ofpbuf_size(packet) - sizeof (struct eth_header);
+ eth = dp_packet_push_uninit(packet, size);
+ *ip_tot_size = dp_packet_size(packet) - sizeof (struct eth_header);
memcpy(eth, header, size);
ip = ip_hdr(eth);
}
static int
-parse_gre_header(struct ofpbuf *packet,
+parse_gre_header(struct dp_packet *packet,
struct flow_tnl *tnl)
{
const struct gre_base_hdr *greh;
}
hlen = gre_header_len(greh->flags);
- if (hlen > ofpbuf_size(packet)) {
+ if (hlen > dp_packet_size(packet)) {
return -EINVAL;
}
if (greh->flags & htons(GRE_CSUM)) {
ovs_be16 pkt_csum;
- pkt_csum = csum(greh, ofpbuf_size(packet) -
+ pkt_csum = csum(greh, dp_packet_size(packet) -
((const unsigned char *)greh -
- (const unsigned char *)ofpbuf_l2(packet)));
+ (const unsigned char *)dp_packet_l2(packet)));
if (pkt_csum) {
return -EINVAL;
}
}
static void
-gre_extract_md(struct dpif_packet *dpif_pkt)
+gre_extract_md(struct dp_packet *packet)
{
- struct ofpbuf *packet = &dpif_pkt->ofpbuf;
- struct pkt_metadata *md = &dpif_pkt->md;
+ struct pkt_metadata *md = &packet->md;
struct flow_tnl *tnl = &md->tunnel;
int hlen = sizeof(struct eth_header) +
sizeof(struct ip_header) + 4;
memset(md, 0, sizeof *md);
- if (hlen > ofpbuf_size(packet)) {
+ if (hlen > dp_packet_size(packet)) {
return;
}
reset_tnl_md(md);
}
- ofpbuf_reset_packet(packet, hlen);
+ dp_packet_reset_packet(packet, hlen);
}
static int
netdev_gre_pop_header(struct netdev *netdev_ OVS_UNUSED,
- struct dpif_packet **pkt, int cnt)
+ struct dp_packet **pkt, int cnt)
{
int i;
}
static void
-netdev_gre_push_header__(struct ofpbuf *packet,
+netdev_gre_push_header__(struct dp_packet *packet,
const void *header, int size)
{
struct gre_base_hdr *greh;
static int
netdev_gre_push_header(const struct netdev *netdev OVS_UNUSED,
- struct dpif_packet **packets, int cnt,
+ struct dp_packet **packets, int cnt,
const struct ovs_action_push_tnl *data)
{
int i;
for (i = 0; i < cnt; i++) {
- netdev_gre_push_header__(&packets[i]->ofpbuf,
- data->header, data->header_len);
+ netdev_gre_push_header__(packets[i], data->header, data->header_len);
packets[i]->md = PKT_METADATA_INITIALIZER(u32_to_odp(data->out_port));
}
return 0;
static int
netdev_gre_build_header(const struct netdev *netdev,
- struct ovs_action_push_tnl *data)
+ struct ovs_action_push_tnl *data,
+ const struct flow *tnl_flow)
{
struct netdev_vport *dev = netdev_vport_cast(netdev);
struct netdev_tunnel_config *tnl_cfg;
if (tnl_cfg->out_key_present) {
greh->flags |= htons(GRE_KEY);
put_16aligned_be32(options, (OVS_FORCE ovs_be32)
- ((OVS_FORCE uint64_t) tnl_cfg->out_key >> 32));
+ ((OVS_FORCE uint64_t) tnl_flow->tunnel.tun_id >> 32));
options++;
}
}
static void
-vxlan_extract_md(struct dpif_packet *dpif_pkt)
+vxlan_extract_md(struct dp_packet *packet)
{
- struct ofpbuf *packet = &dpif_pkt->ofpbuf;
- struct pkt_metadata *md = &dpif_pkt->md;
+ struct pkt_metadata *md = &packet->md;
struct flow_tnl *tnl = &md->tunnel;
struct udp_header *udp;
struct vxlanhdr *vxh;
memset(md, 0, sizeof *md);
- if (VXLAN_HLEN > ofpbuf_size(packet)) {
+ if (VXLAN_HLEN > dp_packet_size(packet)) {
return;
}
tnl->tp_dst = udp->udp_dst;
tnl->tun_id = htonll(ntohl(get_16aligned_be32(&vxh->vx_vni)) >> 8);
- ofpbuf_reset_packet(packet, VXLAN_HLEN);
+ dp_packet_reset_packet(packet, VXLAN_HLEN);
}
static int
netdev_vxlan_pop_header(struct netdev *netdev_ OVS_UNUSED,
- struct dpif_packet **pkt, int cnt)
+ struct dp_packet **pkt, int cnt)
{
int i;
static int
netdev_vxlan_build_header(const struct netdev *netdev,
- struct ovs_action_push_tnl *data)
+ struct ovs_action_push_tnl *data,
+ const struct flow *tnl_flow)
{
struct netdev_vport *dev = netdev_vport_cast(netdev);
struct netdev_tunnel_config *tnl_cfg;
vxh = (struct vxlanhdr *) (udp + 1);
put_16aligned_be32(&vxh->vx_flags, htonl(VXLAN_FLAGS));
- put_16aligned_be32(&vxh->vx_vni, htonl(ntohll(tnl_cfg->out_key) << 8));
+ put_16aligned_be32(&vxh->vx_vni, htonl(ntohll(tnl_flow->tunnel.tun_id) << 8));
ovs_mutex_unlock(&dev->mutex);
data->header_len = VXLAN_HLEN;
}
static ovs_be16
-get_src_port(struct dpif_packet *packet)
+get_src_port(struct dp_packet *packet)
{
uint32_t hash;
- hash = dpif_packet_get_dp_hash(packet);
+ hash = dp_packet_get_dp_hash(packet);
return htons((((uint64_t) hash * (tnl_udp_port_max - tnl_udp_port_min)) >> 32) +
tnl_udp_port_min);
}
static void
-netdev_vxlan_push_header__(struct dpif_packet *packet,
+netdev_vxlan_push_header__(struct dp_packet *packet,
const void *header, int size)
{
struct udp_header *udp;
int ip_tot_size;
- udp = push_ip_header(&packet->ofpbuf, header, size, &ip_tot_size);
+ udp = push_ip_header(packet, header, size, &ip_tot_size);
/* set udp src port */
udp->udp_src = get_src_port(packet);
static int
netdev_vxlan_push_header(const struct netdev *netdev OVS_UNUSED,
- struct dpif_packet **packets, int cnt,
+ struct dp_packet **packets, int cnt,
const struct ovs_action_push_tnl *data)
{
int i;