| 965 | } |
| 966 | |
| 967 | static int |
| 968 | vxlan_socket_init(struct vxlan_socket *vso, struct ifnet *ifp) |
| 969 | { |
| 970 | struct thread *td; |
| 971 | int error; |
| 972 | |
| 973 | td = curthread; |
| 974 | |
| 975 | error = socreate(vso->vxlso_laddr.sa.sa_family, &vso->vxlso_sock, |
| 976 | SOCK_DGRAM, IPPROTO_UDP, td->td_ucred, td); |
| 977 | if (error) { |
| 978 | if_printf(ifp, "cannot create socket: %d\n", error); |
| 979 | return (error); |
| 980 | } |
| 981 | |
| 982 | error = udp_set_kernel_tunneling(vso->vxlso_sock, |
| 983 | vxlan_rcv_udp_packet, NULL, vso); |
| 984 | if (error) { |
| 985 | if_printf(ifp, "cannot set tunneling function: %d\n", error); |
| 986 | return (error); |
| 987 | } |
| 988 | |
| 989 | if (vxlan_reuse_port != 0) { |
| 990 | struct sockopt sopt; |
| 991 | int val = 1; |
| 992 | |
| 993 | bzero(&sopt, sizeof(sopt)); |
| 994 | sopt.sopt_dir = SOPT_SET; |
| 995 | sopt.sopt_level = IPPROTO_IP; |
| 996 | sopt.sopt_name = SO_REUSEPORT; |
| 997 | sopt.sopt_val = &val; |
| 998 | sopt.sopt_valsize = sizeof(val); |
| 999 | error = sosetopt(vso->vxlso_sock, &sopt); |
| 1000 | if (error) { |
| 1001 | if_printf(ifp, |
| 1002 | "cannot set REUSEADDR socket opt: %d\n", error); |
| 1003 | return (error); |
| 1004 | } |
| 1005 | } |
| 1006 | |
| 1007 | return (0); |
| 1008 | } |
| 1009 | |
| 1010 | static int |
| 1011 | vxlan_socket_bind(struct vxlan_socket *vso, struct ifnet *ifp) |
no test coverage detected