2 * Copyright (c) 2010, 2011, 2012, 2013, 2014, 2017 Nicira, Inc.
3 * Copyright (c) 2016 Red Hat, Inc.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 #include "netdev-vport.h"
24 #include <sys/socket.h>
26 #include <netinet/in.h>
27 #include <netinet/ip6.h>
28 #include <sys/ioctl.h>
30 #include "byte-order.h"
35 #include "netdev-native-tnl.h"
36 #include "netdev-provider.h"
37 #include "netdev-vport-private.h"
38 #include "openvswitch/dynamic-string.h"
39 #include "ovs-router.h"
41 #include "poll-loop.h"
42 #include "route-table.h"
44 #include "socket-util.h"
45 #include "unaligned.h"
47 #include "openvswitch/vlog.h"
49 VLOG_DEFINE_THIS_MODULE(netdev_vport
);
51 #define GENEVE_DST_PORT 6081
52 #define VXLAN_DST_PORT 4789
53 #define LISP_DST_PORT 4341
54 #define STT_DST_PORT 7471
56 #define DEFAULT_TTL 64
58 /* Last read of the route-table's change number. */
59 static uint64_t rt_change_seqno
;
61 static int get_patch_config(const struct netdev
*netdev
, struct smap
*args
);
62 static int get_tunnel_config(const struct netdev
*, struct smap
*args
);
63 static bool tunnel_check_status_change__(struct netdev_vport
*);
66 const char *dpif_port
;
67 struct netdev_class netdev_class
;
71 netdev_vport_is_vport_class(const struct netdev_class
*class)
73 return is_vport_class(class);
76 static const struct vport_class
*
77 vport_class_cast(const struct netdev_class
*class)
79 ovs_assert(is_vport_class(class));
80 return CONTAINER_OF(class, struct vport_class
, netdev_class
);
83 static const struct netdev_tunnel_config
*
84 get_netdev_tunnel_config(const struct netdev
*netdev
)
86 return &netdev_vport_cast(netdev
)->tnl_cfg
;
90 netdev_vport_is_patch(const struct netdev
*netdev
)
92 const struct netdev_class
*class = netdev_get_class(netdev
);
94 return class->get_config
== get_patch_config
;
98 netdev_vport_is_layer3(const struct netdev
*dev
)
100 if (is_vport_class(netdev_get_class(dev
))) {
101 struct netdev_vport
*vport
= netdev_vport_cast(dev
);
103 return vport
->tnl_cfg
.is_layer3
;
110 netdev_vport_needs_dst_port(const struct netdev
*dev
)
112 const struct netdev_class
*class = netdev_get_class(dev
);
113 const char *type
= netdev_get_type(dev
);
115 return (class->get_config
== get_tunnel_config
&&
116 (!strcmp("geneve", type
) || !strcmp("vxlan", type
) ||
117 !strcmp("lisp", type
) || !strcmp("stt", type
)) );
121 netdev_vport_class_get_dpif_port(const struct netdev_class
*class)
123 return is_vport_class(class) ? vport_class_cast(class)->dpif_port
: NULL
;
127 netdev_vport_get_dpif_port(const struct netdev
*netdev
,
128 char namebuf
[], size_t bufsize
)
130 const struct netdev_class
*class = netdev_get_class(netdev
);
131 const char *dpif_port
= netdev_vport_class_get_dpif_port(class);
134 return netdev_get_name(netdev
);
137 if (netdev_vport_needs_dst_port(netdev
)) {
138 const struct netdev_vport
*vport
= netdev_vport_cast(netdev
);
141 * Note: IFNAMSIZ is 16 bytes long. Implementations should choose
142 * a dpif port name that is short enough to fit including any
143 * port numbers but assert just in case.
145 BUILD_ASSERT(NETDEV_VPORT_NAME_BUFSIZE
>= IFNAMSIZ
);
146 ovs_assert(strlen(dpif_port
) + 6 < IFNAMSIZ
);
147 snprintf(namebuf
, bufsize
, "%s_%d", dpif_port
,
148 ntohs(vport
->tnl_cfg
.dst_port
));
155 /* Whenever the route-table change number is incremented,
156 * netdev_vport_route_changed() should be called to update
157 * the corresponding tunnel interface status. */
159 netdev_vport_route_changed(void)
161 struct netdev
**vports
;
164 vports
= netdev_get_vports(&n_vports
);
165 for (i
= 0; i
< n_vports
; i
++) {
166 struct netdev
*netdev_
= vports
[i
];
167 struct netdev_vport
*netdev
= netdev_vport_cast(netdev_
);
169 ovs_mutex_lock(&netdev
->mutex
);
170 /* Finds all tunnel vports. */
171 if (ipv6_addr_is_set(&netdev
->tnl_cfg
.ipv6_dst
)) {
172 if (tunnel_check_status_change__(netdev
)) {
173 netdev_change_seq_changed(netdev_
);
176 ovs_mutex_unlock(&netdev
->mutex
);
178 netdev_close(netdev_
);
184 static struct netdev
*
185 netdev_vport_alloc(void)
187 struct netdev_vport
*netdev
= xzalloc(sizeof *netdev
);
192 netdev_vport_construct(struct netdev
*netdev_
)
194 struct netdev_vport
*dev
= netdev_vport_cast(netdev_
);
195 const char *type
= netdev_get_type(netdev_
);
197 ovs_mutex_init(&dev
->mutex
);
198 eth_addr_random(&dev
->etheraddr
);
200 /* Add a default destination port for tunnel ports if none specified. */
201 if (!strcmp(type
, "geneve")) {
202 dev
->tnl_cfg
.dst_port
= htons(GENEVE_DST_PORT
);
203 } else if (!strcmp(type
, "vxlan")) {
204 dev
->tnl_cfg
.dst_port
= htons(VXLAN_DST_PORT
);
205 } else if (!strcmp(type
, "lisp")) {
206 dev
->tnl_cfg
.dst_port
= htons(LISP_DST_PORT
);
207 } else if (!strcmp(type
, "stt")) {
208 dev
->tnl_cfg
.dst_port
= htons(STT_DST_PORT
);
211 dev
->tnl_cfg
.dont_fragment
= true;
212 dev
->tnl_cfg
.ttl
= DEFAULT_TTL
;
217 netdev_vport_destruct(struct netdev
*netdev_
)
219 struct netdev_vport
*netdev
= netdev_vport_cast(netdev_
);
222 ovs_mutex_destroy(&netdev
->mutex
);
226 netdev_vport_dealloc(struct netdev
*netdev_
)
228 struct netdev_vport
*netdev
= netdev_vport_cast(netdev_
);
233 netdev_vport_set_etheraddr(struct netdev
*netdev_
, const struct eth_addr mac
)
235 struct netdev_vport
*netdev
= netdev_vport_cast(netdev_
);
237 ovs_mutex_lock(&netdev
->mutex
);
238 netdev
->etheraddr
= mac
;
239 ovs_mutex_unlock(&netdev
->mutex
);
240 netdev_change_seq_changed(netdev_
);
246 netdev_vport_get_etheraddr(const struct netdev
*netdev_
, struct eth_addr
*mac
)
248 struct netdev_vport
*netdev
= netdev_vport_cast(netdev_
);
250 ovs_mutex_lock(&netdev
->mutex
);
251 *mac
= netdev
->etheraddr
;
252 ovs_mutex_unlock(&netdev
->mutex
);
257 /* Checks if the tunnel status has changed and returns a boolean.
258 * Updates the tunnel status if it has changed. */
260 tunnel_check_status_change__(struct netdev_vport
*netdev
)
261 OVS_REQUIRES(netdev
->mutex
)
263 char iface
[IFNAMSIZ
];
265 struct in6_addr
*route
;
270 route
= &netdev
->tnl_cfg
.ipv6_dst
;
271 mark
= netdev
->tnl_cfg
.egress_pkt_mark
;
272 if (ovs_router_lookup(mark
, route
, iface
, NULL
, &gw
)) {
273 struct netdev
*egress_netdev
;
275 if (!netdev_open(iface
, NULL
, &egress_netdev
)) {
276 status
= netdev_get_carrier(egress_netdev
);
277 netdev_close(egress_netdev
);
281 if (strcmp(netdev
->egress_iface
, iface
)
282 || netdev
->carrier_status
!= status
) {
283 ovs_strlcpy_arrays(netdev
->egress_iface
, iface
);
284 netdev
->carrier_status
= status
;
293 tunnel_get_status(const struct netdev
*netdev_
, struct smap
*smap
)
295 struct netdev_vport
*netdev
= netdev_vport_cast(netdev_
);
297 if (netdev
->egress_iface
[0]) {
298 smap_add(smap
, "tunnel_egress_iface", netdev
->egress_iface
);
300 smap_add(smap
, "tunnel_egress_iface_carrier",
301 netdev
->carrier_status
? "up" : "down");
308 netdev_vport_update_flags(struct netdev
*netdev OVS_UNUSED
,
309 enum netdev_flags off
,
310 enum netdev_flags on OVS_UNUSED
,
311 enum netdev_flags
*old_flagsp
)
313 if (off
& (NETDEV_UP
| NETDEV_PROMISC
)) {
317 *old_flagsp
= NETDEV_UP
| NETDEV_PROMISC
;
322 netdev_vport_run(const struct netdev_class
*netdev_class OVS_UNUSED
)
327 seq
= route_table_get_change_seq();
328 if (rt_change_seqno
!= seq
) {
329 rt_change_seqno
= seq
;
330 netdev_vport_route_changed();
335 netdev_vport_wait(const struct netdev_class
*netdev_class OVS_UNUSED
)
340 seq
= route_table_get_change_seq();
341 if (rt_change_seqno
!= seq
) {
342 poll_immediate_wake();
346 /* Code specific to tunnel types. */
349 parse_key(const struct smap
*args
, const char *name
,
350 bool *present
, bool *flow
)
357 s
= smap_get(args
, name
);
359 s
= smap_get(args
, "key");
367 if (!strcmp(s
, "flow")) {
371 return htonll(strtoull(s
, NULL
, 0));
376 parse_tunnel_ip(const char *value
, bool accept_mcast
, bool *flow
,
377 struct in6_addr
*ipv6
, uint16_t *protocol
)
379 if (!strcmp(value
, "flow")) {
384 if (addr_is_ipv6(value
)) {
385 if (lookup_ipv6(value
, ipv6
)) {
388 if (!accept_mcast
&& ipv6_addr_is_multicast(ipv6
)) {
391 *protocol
= ETH_TYPE_IPV6
;
394 if (lookup_ip(value
, &ip
)) {
397 if (!accept_mcast
&& ip_is_multicast(ip
.s_addr
)) {
400 in6_addr_set_mapped_ipv4(ipv6
, ip
.s_addr
);
401 *protocol
= ETH_TYPE_IP
;
407 set_tunnel_config(struct netdev
*dev_
, const struct smap
*args
, char **errp
)
409 struct netdev_vport
*dev
= netdev_vport_cast(dev_
);
410 const char *name
= netdev_get_name(dev_
);
411 const char *type
= netdev_get_type(dev_
);
412 struct ds errors
= DS_EMPTY_INITIALIZER
;
413 bool needs_dst_port
, has_csum
;
414 uint16_t dst_proto
= 0, src_proto
= 0;
415 struct netdev_tunnel_config tnl_cfg
;
416 struct smap_node
*node
;
419 has_csum
= strstr(type
, "gre") || strstr(type
, "geneve") ||
420 strstr(type
, "stt") || strstr(type
, "vxlan");
421 memset(&tnl_cfg
, 0, sizeof tnl_cfg
);
423 /* Add a default destination port for tunnel ports if none specified. */
424 if (!strcmp(type
, "geneve")) {
425 tnl_cfg
.dst_port
= htons(GENEVE_DST_PORT
);
428 if (!strcmp(type
, "vxlan")) {
429 tnl_cfg
.dst_port
= htons(VXLAN_DST_PORT
);
432 if (!strcmp(type
, "lisp")) {
433 tnl_cfg
.dst_port
= htons(LISP_DST_PORT
);
436 if (!strcmp(type
, "stt")) {
437 tnl_cfg
.dst_port
= htons(STT_DST_PORT
);
440 needs_dst_port
= netdev_vport_needs_dst_port(dev_
);
441 tnl_cfg
.dont_fragment
= true;
443 SMAP_FOR_EACH (node
, args
) {
444 if (!strcmp(node
->key
, "remote_ip")) {
445 err
= parse_tunnel_ip(node
->value
, false, &tnl_cfg
.ip_dst_flow
,
446 &tnl_cfg
.ipv6_dst
, &dst_proto
);
449 ds_put_format(&errors
, "%s: bad %s 'remote_ip'\n", name
, type
);
452 ds_put_format(&errors
,
453 "%s: multicast remote_ip=%s not allowed\n",
457 } else if (!strcmp(node
->key
, "local_ip")) {
458 err
= parse_tunnel_ip(node
->value
, true, &tnl_cfg
.ip_src_flow
,
459 &tnl_cfg
.ipv6_src
, &src_proto
);
462 ds_put_format(&errors
, "%s: bad %s 'local_ip'\n", name
, type
);
465 } else if (!strcmp(node
->key
, "tos")) {
466 if (!strcmp(node
->value
, "inherit")) {
467 tnl_cfg
.tos_inherit
= true;
471 tos
= strtol(node
->value
, &endptr
, 0);
472 if (*endptr
== '\0' && tos
== (tos
& IP_DSCP_MASK
)) {
475 ds_put_format(&errors
, "%s: invalid TOS %s\n", name
,
479 } else if (!strcmp(node
->key
, "ttl")) {
480 if (!strcmp(node
->value
, "inherit")) {
481 tnl_cfg
.ttl_inherit
= true;
483 tnl_cfg
.ttl
= atoi(node
->value
);
485 } else if (!strcmp(node
->key
, "dst_port") && needs_dst_port
) {
486 tnl_cfg
.dst_port
= htons(atoi(node
->value
));
487 } else if (!strcmp(node
->key
, "csum") && has_csum
) {
488 if (!strcmp(node
->value
, "true")) {
491 } else if (!strcmp(node
->key
, "df_default")) {
492 if (!strcmp(node
->value
, "false")) {
493 tnl_cfg
.dont_fragment
= false;
495 } else if (!strcmp(node
->key
, "key") ||
496 !strcmp(node
->key
, "in_key") ||
497 !strcmp(node
->key
, "out_key")) {
498 /* Handled separately below. */
499 } else if (!strcmp(node
->key
, "exts")) {
500 char *str
= xstrdup(node
->value
);
501 char *ext
, *save_ptr
= NULL
;
505 ext
= strtok_r(str
, ",", &save_ptr
);
507 if (!strcmp(type
, "vxlan") && !strcmp(ext
, "gbp")) {
508 tnl_cfg
.exts
|= (1 << OVS_VXLAN_EXT_GBP
);
510 ds_put_format(&errors
, "%s: unknown extension '%s'\n",
514 ext
= strtok_r(NULL
, ",", &save_ptr
);
518 } else if (!strcmp(node
->key
, "egress_pkt_mark")) {
519 tnl_cfg
.egress_pkt_mark
= strtoul(node
->value
, NULL
, 10);
520 tnl_cfg
.set_egress_pkt_mark
= true;
522 ds_put_format(&errors
, "%s: unknown %s argument '%s'\n",
523 name
, type
, node
->key
);
527 if (!ipv6_addr_is_set(&tnl_cfg
.ipv6_dst
) && !tnl_cfg
.ip_dst_flow
) {
528 ds_put_format(&errors
,
529 "%s: %s type requires valid 'remote_ip' argument\n",
534 if (tnl_cfg
.ip_src_flow
&& !tnl_cfg
.ip_dst_flow
) {
535 ds_put_format(&errors
,
536 "%s: %s type requires 'remote_ip=flow' "
537 "with 'local_ip=flow'\n",
542 if (src_proto
&& dst_proto
&& src_proto
!= dst_proto
) {
543 ds_put_format(&errors
,
544 "%s: 'remote_ip' and 'local_ip' "
545 "has to be of the same address family\n",
551 tnl_cfg
.ttl
= DEFAULT_TTL
;
554 tnl_cfg
.in_key
= parse_key(args
, "in_key",
555 &tnl_cfg
.in_key_present
,
556 &tnl_cfg
.in_key_flow
);
558 tnl_cfg
.out_key
= parse_key(args
, "out_key",
559 &tnl_cfg
.out_key_present
,
560 &tnl_cfg
.out_key_flow
);
562 ovs_mutex_lock(&dev
->mutex
);
563 if (memcmp(&dev
->tnl_cfg
, &tnl_cfg
, sizeof tnl_cfg
)) {
564 dev
->tnl_cfg
= tnl_cfg
;
565 tunnel_check_status_change__(dev
);
566 netdev_change_seq_changed(dev_
);
568 ovs_mutex_unlock(&dev
->mutex
);
574 ds_chomp(&errors
, '\n');
575 VLOG_WARN("%s", ds_cstr(&errors
));
577 *errp
= ds_steal_cstr(&errors
);
587 get_tunnel_config(const struct netdev
*dev
, struct smap
*args
)
589 struct netdev_vport
*netdev
= netdev_vport_cast(dev
);
590 struct netdev_tunnel_config tnl_cfg
;
592 ovs_mutex_lock(&netdev
->mutex
);
593 tnl_cfg
= netdev
->tnl_cfg
;
594 ovs_mutex_unlock(&netdev
->mutex
);
596 if (ipv6_addr_is_set(&tnl_cfg
.ipv6_dst
)) {
597 smap_add_ipv6(args
, "remote_ip", &tnl_cfg
.ipv6_dst
);
598 } else if (tnl_cfg
.ip_dst_flow
) {
599 smap_add(args
, "remote_ip", "flow");
602 if (ipv6_addr_is_set(&tnl_cfg
.ipv6_src
)) {
603 smap_add_ipv6(args
, "local_ip", &tnl_cfg
.ipv6_src
);
604 } else if (tnl_cfg
.ip_src_flow
) {
605 smap_add(args
, "local_ip", "flow");
608 if (tnl_cfg
.in_key_flow
&& tnl_cfg
.out_key_flow
) {
609 smap_add(args
, "key", "flow");
610 } else if (tnl_cfg
.in_key_present
&& tnl_cfg
.out_key_present
611 && tnl_cfg
.in_key
== tnl_cfg
.out_key
) {
612 smap_add_format(args
, "key", "%"PRIu64
, ntohll(tnl_cfg
.in_key
));
614 if (tnl_cfg
.in_key_flow
) {
615 smap_add(args
, "in_key", "flow");
616 } else if (tnl_cfg
.in_key_present
) {
617 smap_add_format(args
, "in_key", "%"PRIu64
,
618 ntohll(tnl_cfg
.in_key
));
621 if (tnl_cfg
.out_key_flow
) {
622 smap_add(args
, "out_key", "flow");
623 } else if (tnl_cfg
.out_key_present
) {
624 smap_add_format(args
, "out_key", "%"PRIu64
,
625 ntohll(tnl_cfg
.out_key
));
629 if (tnl_cfg
.ttl_inherit
) {
630 smap_add(args
, "ttl", "inherit");
631 } else if (tnl_cfg
.ttl
!= DEFAULT_TTL
) {
632 smap_add_format(args
, "ttl", "%"PRIu8
, tnl_cfg
.ttl
);
635 if (tnl_cfg
.tos_inherit
) {
636 smap_add(args
, "tos", "inherit");
637 } else if (tnl_cfg
.tos
) {
638 smap_add_format(args
, "tos", "0x%x", tnl_cfg
.tos
);
641 if (tnl_cfg
.dst_port
) {
642 uint16_t dst_port
= ntohs(tnl_cfg
.dst_port
);
643 const char *type
= netdev_get_type(dev
);
645 if ((!strcmp("geneve", type
) && dst_port
!= GENEVE_DST_PORT
) ||
646 (!strcmp("vxlan", type
) && dst_port
!= VXLAN_DST_PORT
) ||
647 (!strcmp("lisp", type
) && dst_port
!= LISP_DST_PORT
) ||
648 (!strcmp("stt", type
) && dst_port
!= STT_DST_PORT
)) {
649 smap_add_format(args
, "dst_port", "%d", dst_port
);
654 smap_add(args
, "csum", "true");
657 if (!tnl_cfg
.dont_fragment
) {
658 smap_add(args
, "df_default", "false");
661 if (tnl_cfg
.set_egress_pkt_mark
) {
662 smap_add_format(args
, "egress_pkt_mark",
663 "%"PRIu32
, tnl_cfg
.egress_pkt_mark
);
668 /* Code specific to patch ports. */
670 /* If 'netdev' is a patch port, returns the name of its peer as a malloc()'d
671 * string that the caller must free.
673 * If 'netdev' is not a patch port, returns NULL. */
675 netdev_vport_patch_peer(const struct netdev
*netdev_
)
679 if (netdev_vport_is_patch(netdev_
)) {
680 struct netdev_vport
*netdev
= netdev_vport_cast(netdev_
);
682 ovs_mutex_lock(&netdev
->mutex
);
684 peer
= xstrdup(netdev
->peer
);
686 ovs_mutex_unlock(&netdev
->mutex
);
693 netdev_vport_inc_rx(const struct netdev
*netdev
,
694 const struct dpif_flow_stats
*stats
)
696 if (is_vport_class(netdev_get_class(netdev
))) {
697 struct netdev_vport
*dev
= netdev_vport_cast(netdev
);
699 ovs_mutex_lock(&dev
->mutex
);
700 dev
->stats
.rx_packets
+= stats
->n_packets
;
701 dev
->stats
.rx_bytes
+= stats
->n_bytes
;
702 ovs_mutex_unlock(&dev
->mutex
);
707 netdev_vport_inc_tx(const struct netdev
*netdev
,
708 const struct dpif_flow_stats
*stats
)
710 if (is_vport_class(netdev_get_class(netdev
))) {
711 struct netdev_vport
*dev
= netdev_vport_cast(netdev
);
713 ovs_mutex_lock(&dev
->mutex
);
714 dev
->stats
.tx_packets
+= stats
->n_packets
;
715 dev
->stats
.tx_bytes
+= stats
->n_bytes
;
716 ovs_mutex_unlock(&dev
->mutex
);
721 get_patch_config(const struct netdev
*dev_
, struct smap
*args
)
723 struct netdev_vport
*dev
= netdev_vport_cast(dev_
);
725 ovs_mutex_lock(&dev
->mutex
);
727 smap_add(args
, "peer", dev
->peer
);
729 ovs_mutex_unlock(&dev
->mutex
);
735 set_patch_config(struct netdev
*dev_
, const struct smap
*args
, char **errp
)
737 struct netdev_vport
*dev
= netdev_vport_cast(dev_
);
738 const char *name
= netdev_get_name(dev_
);
741 peer
= smap_get(args
, "peer");
743 VLOG_ERR_BUF(errp
, "%s: patch type requires valid 'peer' argument",
748 if (smap_count(args
) > 1) {
749 VLOG_ERR_BUF(errp
, "%s: patch type takes only a 'peer' argument",
754 if (!strcmp(name
, peer
)) {
755 VLOG_ERR_BUF(errp
, "%s: patch peer must not be self", name
);
759 ovs_mutex_lock(&dev
->mutex
);
760 if (!dev
->peer
|| strcmp(dev
->peer
, peer
)) {
762 dev
->peer
= xstrdup(peer
);
763 netdev_change_seq_changed(dev_
);
765 ovs_mutex_unlock(&dev
->mutex
);
771 get_stats(const struct netdev
*netdev
, struct netdev_stats
*stats
)
773 struct netdev_vport
*dev
= netdev_vport_cast(netdev
);
775 ovs_mutex_lock(&dev
->mutex
);
776 /* Passing only collected counters */
777 stats
->tx_packets
= dev
->stats
.tx_packets
;
778 stats
->tx_bytes
= dev
->stats
.tx_bytes
;
779 stats
->rx_packets
= dev
->stats
.rx_packets
;
780 stats
->rx_bytes
= dev
->stats
.rx_bytes
;
781 ovs_mutex_unlock(&dev
->mutex
);
787 #define VPORT_FUNCTIONS(GET_CONFIG, SET_CONFIG, \
788 GET_TUNNEL_CONFIG, GET_STATUS, \
790 PUSH_HEADER, POP_HEADER) \
795 netdev_vport_alloc, \
796 netdev_vport_construct, \
797 netdev_vport_destruct, \
798 netdev_vport_dealloc, \
805 NULL, /* get_numa_id */ \
806 NULL, /* set_tx_multiq */ \
809 NULL, /* send_wait */ \
811 netdev_vport_set_etheraddr, \
812 netdev_vport_get_etheraddr, \
813 NULL, /* get_mtu */ \
814 NULL, /* set_mtu */ \
815 NULL, /* get_ifindex */ \
816 NULL, /* get_carrier */ \
817 NULL, /* get_carrier_resets */ \
818 NULL, /* get_miimon */ \
821 NULL, /* get_features */ \
822 NULL, /* set_advertisements */ \
824 NULL, /* set_policing */ \
825 NULL, /* get_qos_types */ \
826 NULL, /* get_qos_capabilities */ \
827 NULL, /* get_qos */ \
828 NULL, /* set_qos */ \
829 NULL, /* get_queue */ \
830 NULL, /* set_queue */ \
831 NULL, /* delete_queue */ \
832 NULL, /* get_queue_stats */ \
833 NULL, /* queue_dump_start */ \
834 NULL, /* queue_dump_next */ \
835 NULL, /* queue_dump_done */ \
836 NULL, /* dump_queue_stats */ \
838 NULL, /* set_in4 */ \
839 NULL, /* get_addr_list */ \
840 NULL, /* add_router */ \
841 NULL, /* get_next_hop */ \
843 NULL, /* arp_lookup */ \
845 netdev_vport_update_flags, \
846 NULL, /* reconfigure */ \
848 NULL, /* rx_alloc */ \
849 NULL, /* rx_construct */ \
850 NULL, /* rx_destruct */ \
851 NULL, /* rx_dealloc */ \
852 NULL, /* rx_recv */ \
853 NULL, /* rx_wait */ \
857 #define TUNNEL_CLASS(NAME, DPIF_PORT, BUILD_HEADER, PUSH_HEADER, POP_HEADER) \
860 VPORT_FUNCTIONS(get_tunnel_config, \
862 get_netdev_tunnel_config, \
864 BUILD_HEADER, PUSH_HEADER, POP_HEADER) }}
867 netdev_vport_tunnel_register(void)
869 /* The name of the dpif_port should be short enough to accomodate adding
870 * a port number to the end if one is necessary. */
871 static const struct vport_class vport_classes
[] = {
872 TUNNEL_CLASS("geneve", "genev_sys", netdev_geneve_build_header
,
873 netdev_tnl_push_udp_header
,
874 netdev_geneve_pop_header
),
875 TUNNEL_CLASS("gre", "gre_sys", netdev_gre_build_header
,
876 netdev_gre_push_header
,
877 netdev_gre_pop_header
),
878 TUNNEL_CLASS("vxlan", "vxlan_sys", netdev_vxlan_build_header
,
879 netdev_tnl_push_udp_header
,
880 netdev_vxlan_pop_header
),
881 TUNNEL_CLASS("lisp", "lisp_sys", NULL
, NULL
, NULL
),
882 TUNNEL_CLASS("stt", "stt_sys", NULL
, NULL
, NULL
),
884 static struct ovsthread_once once
= OVSTHREAD_ONCE_INITIALIZER
;
886 if (ovsthread_once_start(&once
)) {
889 for (i
= 0; i
< ARRAY_SIZE(vport_classes
); i
++) {
890 netdev_register_provider(&vport_classes
[i
].netdev_class
);
893 unixctl_command_register("tnl/egress_port_range", "min max", 0, 2,
894 netdev_tnl_egress_port_range
, NULL
);
896 ovsthread_once_done(&once
);
901 netdev_vport_patch_register(void)
903 static const struct vport_class patch_class
=
906 VPORT_FUNCTIONS(get_patch_config
,
909 NULL
, NULL
, NULL
, NULL
) }};
910 netdev_register_provider(&patch_class
.netdev_class
);