MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vxlan_setup_socket

Function vxlan_setup_socket

freebsd/net/if_vxlan.c:1510–1580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1508}
1509
1510static int
1511vxlan_setup_socket(struct vxlan_softc *sc)
1512{
1513 struct vxlan_socket *vso;
1514 struct ifnet *ifp;
1515 union vxlan_sockaddr *saddr, *daddr;
1516 int multicast, error;
1517
1518 vso = NULL;
1519 ifp = sc->vxl_ifp;
1520 saddr = &sc->vxl_src_addr;
1521 daddr = &sc->vxl_dst_addr;
1522
1523 multicast = vxlan_sockaddr_in_multicast(daddr);
1524 MPASS(multicast != -1);
1525 sc->vxl_vso_mc_index = -1;
1526
1527 /*
1528 * Try to create the socket. If that fails, attempt to use an
1529 * existing socket.
1530 */
1531 error = vxlan_socket_create(ifp, multicast, saddr, &vso);
1532 if (error) {
1533 if (multicast != 0)
1534 vso = vxlan_socket_mc_lookup(saddr);
1535 else
1536 vso = vxlan_socket_lookup(saddr);
1537
1538 if (vso == NULL) {
1539 if_printf(ifp, "cannot create socket (error: %d), "
1540 "and no existing socket found\n", error);
1541 goto out;
1542 }
1543 }
1544
1545 if (multicast != 0) {
1546 error = vxlan_setup_multicast(sc);
1547 if (error)
1548 goto out;
1549
1550 error = vxlan_socket_mc_add_group(vso, daddr, saddr,
1551 sc->vxl_mc_ifindex, &sc->vxl_vso_mc_index);
1552 if (error)
1553 goto out;
1554 }
1555
1556 sc->vxl_sock = vso;
1557 error = vxlan_socket_insert_softc(vso, sc);
1558 if (error) {
1559 sc->vxl_sock = NULL;
1560 if_printf(ifp, "network identifier %d already exists in "
1561 "this socket\n", sc->vxl_vni);
1562 goto out;
1563 }
1564
1565 return (0);
1566
1567out:

Callers 1

vxlan_initFunction · 0.85

Calls 11

vxlan_socket_createFunction · 0.85
vxlan_socket_mc_lookupFunction · 0.85
vxlan_socket_lookupFunction · 0.85
if_printfFunction · 0.85
vxlan_setup_multicastFunction · 0.85
vxlan_free_multicastFunction · 0.85
vxlan_socket_releaseFunction · 0.85

Tested by

no test coverage detected