1ccb1352eSJesse Gross /* 2caf2ee14SRaju Subramanian * Copyright (c) 2007-2012 Nicira, Inc. 3ccb1352eSJesse Gross * 4ccb1352eSJesse Gross * This program is free software; you can redistribute it and/or 5ccb1352eSJesse Gross * modify it under the terms of version 2 of the GNU General Public 6ccb1352eSJesse Gross * License as published by the Free Software Foundation. 7ccb1352eSJesse Gross * 8ccb1352eSJesse Gross * This program is distributed in the hope that it will be useful, but 9ccb1352eSJesse Gross * WITHOUT ANY WARRANTY; without even the implied warranty of 10ccb1352eSJesse Gross * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11ccb1352eSJesse Gross * General Public License for more details. 12ccb1352eSJesse Gross * 13ccb1352eSJesse Gross * You should have received a copy of the GNU General Public License 14ccb1352eSJesse Gross * along with this program; if not, write to the Free Software 15ccb1352eSJesse Gross * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 16ccb1352eSJesse Gross * 02110-1301, USA 17ccb1352eSJesse Gross */ 18ccb1352eSJesse Gross 19ccb1352eSJesse Gross #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 20ccb1352eSJesse Gross 21ccb1352eSJesse Gross #include <linux/if_arp.h> 22ccb1352eSJesse Gross #include <linux/if_bridge.h> 23ccb1352eSJesse Gross #include <linux/if_vlan.h> 24ccb1352eSJesse Gross #include <linux/kernel.h> 25ccb1352eSJesse Gross #include <linux/llc.h> 26ccb1352eSJesse Gross #include <linux/rtnetlink.h> 27ccb1352eSJesse Gross #include <linux/skbuff.h> 282537b4ddSJiri Pirko #include <linux/openvswitch.h> 29ccb1352eSJesse Gross 30614732eaSThomas Graf #include <net/udp.h> 31614732eaSThomas Graf #include <net/ip_tunnels.h> 32614732eaSThomas Graf #include <net/rtnetlink.h> 33614732eaSThomas Graf #include <net/vxlan.h> 34ccb1352eSJesse Gross 35ccb1352eSJesse Gross #include "datapath.h" 36614732eaSThomas Graf #include "vport.h" 37ccb1352eSJesse Gross #include "vport-internal_dev.h" 38ccb1352eSJesse Gross #include "vport-netdev.h" 39ccb1352eSJesse Gross 4062b9c8d0SThomas Graf static struct vport_ops ovs_netdev_vport_ops; 4162b9c8d0SThomas Graf 42ccb1352eSJesse Gross /* Must be called with rcu_read_lock. */ 43ccb1352eSJesse Gross static void netdev_port_receive(struct vport *vport, struct sk_buff *skb) 44ccb1352eSJesse Gross { 45d9d59089SJesse Gross if (unlikely(!vport)) 46d9d59089SJesse Gross goto error; 47d9d59089SJesse Gross 48d9d59089SJesse Gross if (unlikely(skb_warn_if_lro(skb))) 49d9d59089SJesse Gross goto error; 50ccb1352eSJesse Gross 51ccb1352eSJesse Gross /* Make our own copy of the packet. Otherwise we will mangle the 52ccb1352eSJesse Gross * packet for anyone who came before us (e.g. tcpdump via AF_PACKET). 53d176ca2aSCong Wang */ 54ccb1352eSJesse Gross skb = skb_share_check(skb, GFP_ATOMIC); 55ccb1352eSJesse Gross if (unlikely(!skb)) 56ccb1352eSJesse Gross return; 57ccb1352eSJesse Gross 58ccb1352eSJesse Gross skb_push(skb, ETH_HLEN); 59b34df5e8SPravin B Shelar ovs_skb_postpush_rcsum(skb, skb->data, ETH_HLEN); 60b34df5e8SPravin B Shelar 61*597798e4SThomas Graf ovs_vport_receive(vport, skb, skb_tunnel_info(skb, AF_INET)); 62d9d59089SJesse Gross return; 63d9d59089SJesse Gross 64d9d59089SJesse Gross error: 65d9d59089SJesse Gross kfree_skb(skb); 66ccb1352eSJesse Gross } 67ccb1352eSJesse Gross 68ccb1352eSJesse Gross /* Called with rcu_read_lock and bottom-halves disabled. */ 69ccb1352eSJesse Gross static rx_handler_result_t netdev_frame_hook(struct sk_buff **pskb) 70ccb1352eSJesse Gross { 71ccb1352eSJesse Gross struct sk_buff *skb = *pskb; 72ccb1352eSJesse Gross struct vport *vport; 73ccb1352eSJesse Gross 74ccb1352eSJesse Gross if (unlikely(skb->pkt_type == PACKET_LOOPBACK)) 75ccb1352eSJesse Gross return RX_HANDLER_PASS; 76ccb1352eSJesse Gross 77ccb1352eSJesse Gross vport = ovs_netdev_get_vport(skb->dev); 78ccb1352eSJesse Gross 79ccb1352eSJesse Gross netdev_port_receive(vport, skb); 80ccb1352eSJesse Gross 81ccb1352eSJesse Gross return RX_HANDLER_CONSUMED; 82ccb1352eSJesse Gross } 83ccb1352eSJesse Gross 8412eb18f7SThomas Graf static struct net_device *get_dpdev(const struct datapath *dp) 852537b4ddSJiri Pirko { 862537b4ddSJiri Pirko struct vport *local; 872537b4ddSJiri Pirko 882537b4ddSJiri Pirko local = ovs_vport_ovsl(dp, OVSP_LOCAL); 892537b4ddSJiri Pirko BUG_ON(!local); 90be4ace6eSThomas Graf return local->dev; 912537b4ddSJiri Pirko } 922537b4ddSJiri Pirko 93be4ace6eSThomas Graf static struct vport *netdev_link(struct vport *vport, const char *name) 94ccb1352eSJesse Gross { 95ccb1352eSJesse Gross int err; 96ccb1352eSJesse Gross 97be4ace6eSThomas Graf vport->dev = dev_get_by_name(ovs_dp_get_net(vport->dp), name); 98be4ace6eSThomas Graf if (!vport->dev) { 99ccb1352eSJesse Gross err = -ENODEV; 100ccb1352eSJesse Gross goto error_free_vport; 101ccb1352eSJesse Gross } 102ccb1352eSJesse Gross 103be4ace6eSThomas Graf if (vport->dev->flags & IFF_LOOPBACK || 104be4ace6eSThomas Graf vport->dev->type != ARPHRD_ETHER || 105be4ace6eSThomas Graf ovs_is_internal_dev(vport->dev)) { 106ccb1352eSJesse Gross err = -EINVAL; 107ccb1352eSJesse Gross goto error_put; 108ccb1352eSJesse Gross } 109ccb1352eSJesse Gross 1108e4e1713SPravin B Shelar rtnl_lock(); 111be4ace6eSThomas Graf err = netdev_master_upper_dev_link(vport->dev, 1122537b4ddSJiri Pirko get_dpdev(vport->dp)); 1132537b4ddSJiri Pirko if (err) 1142537b4ddSJiri Pirko goto error_unlock; 1152537b4ddSJiri Pirko 116be4ace6eSThomas Graf err = netdev_rx_handler_register(vport->dev, netdev_frame_hook, 117ccb1352eSJesse Gross vport); 118ccb1352eSJesse Gross if (err) 1192537b4ddSJiri Pirko goto error_master_upper_dev_unlink; 120ccb1352eSJesse Gross 121be4ace6eSThomas Graf dev_disable_lro(vport->dev); 122be4ace6eSThomas Graf dev_set_promiscuity(vport->dev, 1); 123be4ace6eSThomas Graf vport->dev->priv_flags |= IFF_OVS_DATAPATH; 1248e4e1713SPravin B Shelar rtnl_unlock(); 125ccb1352eSJesse Gross 126ccb1352eSJesse Gross return vport; 127ccb1352eSJesse Gross 1282537b4ddSJiri Pirko error_master_upper_dev_unlink: 129be4ace6eSThomas Graf netdev_upper_dev_unlink(vport->dev, get_dpdev(vport->dp)); 1308e4e1713SPravin B Shelar error_unlock: 1318e4e1713SPravin B Shelar rtnl_unlock(); 132ccb1352eSJesse Gross error_put: 133be4ace6eSThomas Graf dev_put(vport->dev); 134ccb1352eSJesse Gross error_free_vport: 135ccb1352eSJesse Gross ovs_vport_free(vport); 136ccb1352eSJesse Gross return ERR_PTR(err); 137ccb1352eSJesse Gross } 138ccb1352eSJesse Gross 139be4ace6eSThomas Graf static struct vport *netdev_create(const struct vport_parms *parms) 140be4ace6eSThomas Graf { 141be4ace6eSThomas Graf struct vport *vport; 142be4ace6eSThomas Graf 143be4ace6eSThomas Graf vport = ovs_vport_alloc(0, &ovs_netdev_vport_ops, parms); 144be4ace6eSThomas Graf if (IS_ERR(vport)) 145be4ace6eSThomas Graf return vport; 146be4ace6eSThomas Graf 147be4ace6eSThomas Graf return netdev_link(vport, parms->name); 148be4ace6eSThomas Graf } 149be4ace6eSThomas Graf 15092eb1d47SJesse Gross static void free_port_rcu(struct rcu_head *rcu) 15192eb1d47SJesse Gross { 152be4ace6eSThomas Graf struct vport *vport = container_of(rcu, struct vport, rcu); 15392eb1d47SJesse Gross 154614732eaSThomas Graf if (vport->dev) 155be4ace6eSThomas Graf dev_put(vport->dev); 156be4ace6eSThomas Graf ovs_vport_free(vport); 15792eb1d47SJesse Gross } 15892eb1d47SJesse Gross 159b07c2651SAlexei Starovoitov void ovs_netdev_detach_dev(struct vport *vport) 160b07c2651SAlexei Starovoitov { 161b07c2651SAlexei Starovoitov ASSERT_RTNL(); 162be4ace6eSThomas Graf vport->dev->priv_flags &= ~IFF_OVS_DATAPATH; 163be4ace6eSThomas Graf netdev_rx_handler_unregister(vport->dev); 164be4ace6eSThomas Graf netdev_upper_dev_unlink(vport->dev, 165be4ace6eSThomas Graf netdev_master_upper_dev_get(vport->dev)); 166be4ace6eSThomas Graf dev_set_promiscuity(vport->dev, -1); 167b07c2651SAlexei Starovoitov } 168b07c2651SAlexei Starovoitov 169ccb1352eSJesse Gross static void netdev_destroy(struct vport *vport) 170ccb1352eSJesse Gross { 1718e4e1713SPravin B Shelar rtnl_lock(); 172be4ace6eSThomas Graf if (vport->dev->priv_flags & IFF_OVS_DATAPATH) 173b07c2651SAlexei Starovoitov ovs_netdev_detach_dev(vport); 1748e4e1713SPravin B Shelar rtnl_unlock(); 175ccb1352eSJesse Gross 176be4ace6eSThomas Graf call_rcu(&vport->rcu, free_port_rcu); 177ccb1352eSJesse Gross } 178ccb1352eSJesse Gross 17995c96174SEric Dumazet static unsigned int packet_length(const struct sk_buff *skb) 180ccb1352eSJesse Gross { 18195c96174SEric Dumazet unsigned int length = skb->len - ETH_HLEN; 182ccb1352eSJesse Gross 183ccb1352eSJesse Gross if (skb->protocol == htons(ETH_P_8021Q)) 184ccb1352eSJesse Gross length -= VLAN_HLEN; 185ccb1352eSJesse Gross 186ccb1352eSJesse Gross return length; 187ccb1352eSJesse Gross } 188ccb1352eSJesse Gross 189ccb1352eSJesse Gross static int netdev_send(struct vport *vport, struct sk_buff *skb) 190ccb1352eSJesse Gross { 191be4ace6eSThomas Graf int mtu = vport->dev->mtu; 192ccb1352eSJesse Gross int len; 193ccb1352eSJesse Gross 194ccb1352eSJesse Gross if (unlikely(packet_length(skb) > mtu && !skb_is_gso(skb))) { 195e87cc472SJoe Perches net_warn_ratelimited("%s: dropped over-mtu packet: %d > %d\n", 196be4ace6eSThomas Graf vport->dev->name, 197e87cc472SJoe Perches packet_length(skb), mtu); 19891b7514cSPravin B Shelar goto drop; 199ccb1352eSJesse Gross } 200ccb1352eSJesse Gross 201be4ace6eSThomas Graf skb->dev = vport->dev; 202ccb1352eSJesse Gross len = skb->len; 203ccb1352eSJesse Gross dev_queue_xmit(skb); 204ccb1352eSJesse Gross 205ccb1352eSJesse Gross return len; 206ccb1352eSJesse Gross 20791b7514cSPravin B Shelar drop: 208ccb1352eSJesse Gross kfree_skb(skb); 209ccb1352eSJesse Gross return 0; 210ccb1352eSJesse Gross } 211ccb1352eSJesse Gross 212ccb1352eSJesse Gross /* Returns null if this device is not attached to a datapath. */ 213ccb1352eSJesse Gross struct vport *ovs_netdev_get_vport(struct net_device *dev) 214ccb1352eSJesse Gross { 215ccb1352eSJesse Gross if (likely(dev->priv_flags & IFF_OVS_DATAPATH)) 216ccb1352eSJesse Gross return (struct vport *) 217ccb1352eSJesse Gross rcu_dereference_rtnl(dev->rx_handler_data); 218ccb1352eSJesse Gross else 219ccb1352eSJesse Gross return NULL; 220ccb1352eSJesse Gross } 221ccb1352eSJesse Gross 22262b9c8d0SThomas Graf static struct vport_ops ovs_netdev_vport_ops = { 223ccb1352eSJesse Gross .type = OVS_VPORT_TYPE_NETDEV, 224ccb1352eSJesse Gross .create = netdev_create, 225ccb1352eSJesse Gross .destroy = netdev_destroy, 226ccb1352eSJesse Gross .send = netdev_send, 227ccb1352eSJesse Gross }; 22862b9c8d0SThomas Graf 229614732eaSThomas Graf /* Compat code for old userspace. */ 230614732eaSThomas Graf #if IS_ENABLED(CONFIG_VXLAN) 231614732eaSThomas Graf static struct vport_ops ovs_vxlan_netdev_vport_ops; 232614732eaSThomas Graf 233614732eaSThomas Graf static int vxlan_get_options(const struct vport *vport, struct sk_buff *skb) 234614732eaSThomas Graf { 235614732eaSThomas Graf struct vxlan_dev *vxlan = netdev_priv(vport->dev); 236614732eaSThomas Graf __be16 dst_port = vxlan->cfg.dst_port; 237614732eaSThomas Graf 238614732eaSThomas Graf if (nla_put_u16(skb, OVS_TUNNEL_ATTR_DST_PORT, ntohs(dst_port))) 239614732eaSThomas Graf return -EMSGSIZE; 240614732eaSThomas Graf 241614732eaSThomas Graf if (vxlan->flags & VXLAN_F_GBP) { 242614732eaSThomas Graf struct nlattr *exts; 243614732eaSThomas Graf 244614732eaSThomas Graf exts = nla_nest_start(skb, OVS_TUNNEL_ATTR_EXTENSION); 245614732eaSThomas Graf if (!exts) 246614732eaSThomas Graf return -EMSGSIZE; 247614732eaSThomas Graf 248614732eaSThomas Graf if (vxlan->flags & VXLAN_F_GBP && 249614732eaSThomas Graf nla_put_flag(skb, OVS_VXLAN_EXT_GBP)) 250614732eaSThomas Graf return -EMSGSIZE; 251614732eaSThomas Graf 252614732eaSThomas Graf nla_nest_end(skb, exts); 253614732eaSThomas Graf } 254614732eaSThomas Graf 255614732eaSThomas Graf return 0; 256614732eaSThomas Graf } 257614732eaSThomas Graf 258614732eaSThomas Graf static const struct nla_policy exts_policy[OVS_VXLAN_EXT_MAX + 1] = { 259614732eaSThomas Graf [OVS_VXLAN_EXT_GBP] = { .type = NLA_FLAG, }, 260614732eaSThomas Graf }; 261614732eaSThomas Graf 262614732eaSThomas Graf static int vxlan_configure_exts(struct vport *vport, struct nlattr *attr, 263614732eaSThomas Graf struct vxlan_config *conf) 264614732eaSThomas Graf { 265614732eaSThomas Graf struct nlattr *exts[OVS_VXLAN_EXT_MAX + 1]; 266614732eaSThomas Graf int err; 267614732eaSThomas Graf 268614732eaSThomas Graf if (nla_len(attr) < sizeof(struct nlattr)) 269614732eaSThomas Graf return -EINVAL; 270614732eaSThomas Graf 271614732eaSThomas Graf err = nla_parse_nested(exts, OVS_VXLAN_EXT_MAX, attr, exts_policy); 272614732eaSThomas Graf if (err < 0) 273614732eaSThomas Graf return err; 274614732eaSThomas Graf 275614732eaSThomas Graf if (exts[OVS_VXLAN_EXT_GBP]) 276614732eaSThomas Graf conf->flags |= VXLAN_F_GBP; 277614732eaSThomas Graf 278614732eaSThomas Graf return 0; 279614732eaSThomas Graf } 280614732eaSThomas Graf 281614732eaSThomas Graf static struct vport *vxlan_tnl_create(const struct vport_parms *parms) 282614732eaSThomas Graf { 283614732eaSThomas Graf struct net *net = ovs_dp_get_net(parms->dp); 284614732eaSThomas Graf struct nlattr *options = parms->options; 285614732eaSThomas Graf struct net_device *dev; 286614732eaSThomas Graf struct vport *vport; 287614732eaSThomas Graf struct nlattr *a; 288614732eaSThomas Graf int err; 289614732eaSThomas Graf struct vxlan_config conf = { 290614732eaSThomas Graf .no_share = true, 291614732eaSThomas Graf .flags = VXLAN_F_FLOW_BASED | VXLAN_F_COLLECT_METADATA, 292614732eaSThomas Graf }; 293614732eaSThomas Graf 294614732eaSThomas Graf if (!options) { 295614732eaSThomas Graf err = -EINVAL; 296614732eaSThomas Graf goto error; 297614732eaSThomas Graf } 298614732eaSThomas Graf 299614732eaSThomas Graf a = nla_find_nested(options, OVS_TUNNEL_ATTR_DST_PORT); 300614732eaSThomas Graf if (a && nla_len(a) == sizeof(u16)) { 301614732eaSThomas Graf conf.dst_port = htons(nla_get_u16(a)); 302614732eaSThomas Graf } else { 303614732eaSThomas Graf /* Require destination port from userspace. */ 304614732eaSThomas Graf err = -EINVAL; 305614732eaSThomas Graf goto error; 306614732eaSThomas Graf } 307614732eaSThomas Graf 308614732eaSThomas Graf vport = ovs_vport_alloc(0, &ovs_vxlan_netdev_vport_ops, parms); 309614732eaSThomas Graf if (IS_ERR(vport)) 310614732eaSThomas Graf return vport; 311614732eaSThomas Graf 312614732eaSThomas Graf a = nla_find_nested(options, OVS_TUNNEL_ATTR_EXTENSION); 313614732eaSThomas Graf if (a) { 314614732eaSThomas Graf err = vxlan_configure_exts(vport, a, &conf); 315614732eaSThomas Graf if (err) { 316614732eaSThomas Graf ovs_vport_free(vport); 317614732eaSThomas Graf goto error; 318614732eaSThomas Graf } 319614732eaSThomas Graf } 320614732eaSThomas Graf 321614732eaSThomas Graf rtnl_lock(); 322614732eaSThomas Graf dev = vxlan_dev_create(net, parms->name, NET_NAME_USER, &conf); 323614732eaSThomas Graf if (IS_ERR(dev)) { 324614732eaSThomas Graf rtnl_unlock(); 325614732eaSThomas Graf ovs_vport_free(vport); 326614732eaSThomas Graf return ERR_CAST(dev); 327614732eaSThomas Graf } 328614732eaSThomas Graf 329614732eaSThomas Graf dev_change_flags(dev, dev->flags | IFF_UP); 330614732eaSThomas Graf rtnl_unlock(); 331614732eaSThomas Graf return vport; 332614732eaSThomas Graf error: 333614732eaSThomas Graf return ERR_PTR(err); 334614732eaSThomas Graf } 335614732eaSThomas Graf 336614732eaSThomas Graf static struct vport *vxlan_create(const struct vport_parms *parms) 337614732eaSThomas Graf { 338614732eaSThomas Graf struct vport *vport; 339614732eaSThomas Graf 340614732eaSThomas Graf vport = vxlan_tnl_create(parms); 341614732eaSThomas Graf if (IS_ERR(vport)) 342614732eaSThomas Graf return vport; 343614732eaSThomas Graf 344614732eaSThomas Graf return netdev_link(vport, parms->name); 345614732eaSThomas Graf } 346614732eaSThomas Graf 347614732eaSThomas Graf static void vxlan_destroy(struct vport *vport) 348614732eaSThomas Graf { 349614732eaSThomas Graf rtnl_lock(); 350614732eaSThomas Graf if (vport->dev->priv_flags & IFF_OVS_DATAPATH) 351614732eaSThomas Graf ovs_netdev_detach_dev(vport); 352614732eaSThomas Graf 353614732eaSThomas Graf /* Early release so we can unregister the device */ 354614732eaSThomas Graf dev_put(vport->dev); 355614732eaSThomas Graf rtnl_delete_link(vport->dev); 356614732eaSThomas Graf vport->dev = NULL; 357614732eaSThomas Graf rtnl_unlock(); 358614732eaSThomas Graf 359614732eaSThomas Graf call_rcu(&vport->rcu, free_port_rcu); 360614732eaSThomas Graf } 361614732eaSThomas Graf 362614732eaSThomas Graf static int vxlan_get_egress_tun_info(struct vport *vport, struct sk_buff *skb, 363614732eaSThomas Graf struct ip_tunnel_info *egress_tun_info) 364614732eaSThomas Graf { 365614732eaSThomas Graf struct vxlan_dev *vxlan = netdev_priv(vport->dev); 366614732eaSThomas Graf struct net *net = ovs_dp_get_net(vport->dp); 367614732eaSThomas Graf __be16 dst_port = vxlan_dev_dst_port(vxlan); 368614732eaSThomas Graf __be16 src_port; 369614732eaSThomas Graf int port_min; 370614732eaSThomas Graf int port_max; 371614732eaSThomas Graf 372614732eaSThomas Graf inet_get_local_port_range(net, &port_min, &port_max); 373614732eaSThomas Graf src_port = udp_flow_src_port(net, skb, 0, 0, true); 374614732eaSThomas Graf 375614732eaSThomas Graf return ovs_tunnel_get_egress_info(egress_tun_info, net, 376614732eaSThomas Graf OVS_CB(skb)->egress_tun_info, 377614732eaSThomas Graf IPPROTO_UDP, skb->mark, 378614732eaSThomas Graf src_port, dst_port); 379614732eaSThomas Graf } 380614732eaSThomas Graf 381614732eaSThomas Graf static struct vport_ops ovs_vxlan_netdev_vport_ops = { 382614732eaSThomas Graf .type = OVS_VPORT_TYPE_VXLAN, 383614732eaSThomas Graf .create = vxlan_create, 384614732eaSThomas Graf .destroy = vxlan_destroy, 385614732eaSThomas Graf .get_options = vxlan_get_options, 386614732eaSThomas Graf .send = netdev_send, 387614732eaSThomas Graf .get_egress_tun_info = vxlan_get_egress_tun_info, 388614732eaSThomas Graf }; 389614732eaSThomas Graf 390614732eaSThomas Graf static int vxlan_compat_init(void) 391614732eaSThomas Graf { 392614732eaSThomas Graf return ovs_vport_ops_register(&ovs_vxlan_netdev_vport_ops); 393614732eaSThomas Graf } 394614732eaSThomas Graf 395614732eaSThomas Graf static void vxlan_compat_exit(void) 396614732eaSThomas Graf { 397614732eaSThomas Graf ovs_vport_ops_unregister(&ovs_vxlan_netdev_vport_ops); 398614732eaSThomas Graf } 399614732eaSThomas Graf #else 400614732eaSThomas Graf static int vxlan_compat_init(void) 401614732eaSThomas Graf { 402614732eaSThomas Graf return 0; 403614732eaSThomas Graf } 404614732eaSThomas Graf 405614732eaSThomas Graf static void vxlan_compat_exit(void) 406614732eaSThomas Graf { 407614732eaSThomas Graf } 408614732eaSThomas Graf #endif 409614732eaSThomas Graf 41062b9c8d0SThomas Graf int __init ovs_netdev_init(void) 41162b9c8d0SThomas Graf { 412614732eaSThomas Graf int err; 413614732eaSThomas Graf 414614732eaSThomas Graf err = ovs_vport_ops_register(&ovs_netdev_vport_ops); 415614732eaSThomas Graf if (err) 416614732eaSThomas Graf return err; 417614732eaSThomas Graf err = vxlan_compat_init(); 418614732eaSThomas Graf if (err) 419614732eaSThomas Graf vxlan_compat_exit(); 420614732eaSThomas Graf return err; 42162b9c8d0SThomas Graf } 42262b9c8d0SThomas Graf 42362b9c8d0SThomas Graf void ovs_netdev_exit(void) 42462b9c8d0SThomas Graf { 42562b9c8d0SThomas Graf ovs_vport_ops_unregister(&ovs_netdev_vport_ops); 426614732eaSThomas Graf vxlan_compat_exit(); 42762b9c8d0SThomas Graf } 428