datapath/linux/compat/vxlan.c
/* Create new listen socket if needed */
Create new listen socket if needed
Create new listen socket if needed
static struct vxlan_sock *vxlan_socket_create(struct net *net, bool ipv6,
					      __be16 port, u32 flags)
{
	struct vxlan_net *vn = net_generic(net, vxlan_net_id);
	struct vxlan_sock *vs;
	struct socket *sock;
	unsigned int h;
	struct udp_tunnel_sock_cfg tunnel_cfg;
	vs = kzalloc(sizeof(*vs), GFP_KERNEL);
	if (!vs)
		return ERR_PTR(-ENOMEM);
	for (h = 0; h < VNI_HASH_SIZE; ++h)
		INIT_HLIST_HEAD(&vs->vni_list[h]);
	sock = vxlan_create_sock(net, ipv6, port, flags);
	if (IS_ERR(sock)) {
		kfree(vs);
		return ERR_CAST(sock);
	}
	vs->sock = sock;
	atomic_set(&vs->refcnt, 1);
	vs->flags = (flags & VXLAN_F_RCV_FLAGS);
#ifdef HAVE_UDP_OFFLOAD
	vs->udp_offloads.port = port;
	vs->udp_offloads.callbacks.gro_receive  = vxlan_gro_receive;
	vs->udp_offloads.callbacks.gro_complete = vxlan_gro_complete;
#endif
	spin_lock(&vn->sock_lock);
	hlist_add_head_rcu(&vs->hlist, vs_head(net, port));
	vxlan_notify_add_rx_port(vs);
	spin_unlock(&vn->sock_lock);
	memset(&tunnel_cfg, 0, sizeof(tunnel_cfg));
	tunnel_cfg.sk_user_data = vs;
	tunnel_cfg.encap_type = 1;
	tunnel_cfg.encap_rcv = vxlan_rcv;
	tunnel_cfg.encap_destroy = NULL;
#ifdef HAVE_UDP_TUNNEL_SOCK_CFG_GRO_RECEIVE
	tunnel_cfg.gro_receive = vxlan_gro_receive;
	tunnel_cfg.gro_complete = vxlan_gro_complete;
#endif
	setup_udp_tunnel_sock(net, sock, &tunnel_cfg);
	return vs;
}
static struct vxlan_sock * vxlan_socket_create ( struct net * net , bool ipv6 , __be16 port , u32 flags ) { struct vxlan_net * vn = net_generic ( net , vxlan_net_id ) ; struct vxlan_sock * vs ; struct socket * sock ; unsigned int h ; struct udp_tunnel_sock_cfg tunnel_cfg ; vs = kzalloc ( sizeof ( * vs ) , GFP_KERNEL ) ; if ( ! vs ) return ERR_PTR ( - ENOMEM ) ; for ( h = 0 ; h < VNI_HASH_SIZE ; ++ h ) INIT_HLIST_HEAD ( & vs -> vni_list [ h ] ) ; sock = vxlan_create_sock ( net , ipv6 , port , flags ) ; if ( IS_ERR ( sock ) ) { kfree ( vs ) ; return ERR_CAST ( sock ) ; } vs -> sock = sock ; atomic_set ( & vs -> refcnt , 1 ) ; vs -> flags = ( flags & VXLAN_F_RCV_FLAGS ) ; #ifdef HAVE_UDP_OFFLOAD vs -> udp_offloads . port = port ; vs -> udp_offloads . callbacks . gro_receive = vxlan_gro_receive ; vs -> udp_offloads . callbacks . gro_complete = vxlan_gro_complete ; #endif spin_lock ( & vn -> sock_lock ) ; hlist_add_head_rcu ( & vs -> hlist , vs_head ( net , port ) ) ; vxlan_notify_add_rx_port ( vs ) ; spin_unlock ( & vn -> sock_lock ) ; memset ( & tunnel_cfg , 0 , sizeof ( tunnel_cfg ) ) ; tunnel_cfg . sk_user_data = vs ; tunnel_cfg . encap_type = 1 ; tunnel_cfg . encap_rcv = vxlan_rcv ; tunnel_cfg . encap_destroy = NULL ; #ifdef HAVE_UDP_TUNNEL_SOCK_CFG_GRO_RECEIVE tunnel_cfg . gro_receive = vxlan_gro_receive ; tunnel_cfg . gro_complete = vxlan_gro_complete ; #endif setup_udp_tunnel_sock ( net , sock , & tunnel_cfg ) ; return vs ; }
Create new listen socket if needed
Create new listen socket if needed
/* Mark socket as an encapsulation socket. */