| 1630 | } |
| 1631 | |
| 1632 | static int |
| 1633 | vxlan_valid_init_config(struct vxlan_softc *sc) |
| 1634 | { |
| 1635 | const char *reason; |
| 1636 | |
| 1637 | if (vxlan_check_vni(sc->vxl_vni) != 0) { |
| 1638 | reason = "invalid virtual network identifier specified"; |
| 1639 | goto fail; |
| 1640 | } |
| 1641 | |
| 1642 | if (vxlan_sockaddr_supported(&sc->vxl_src_addr, 1) == 0) { |
| 1643 | reason = "source address type is not supported"; |
| 1644 | goto fail; |
| 1645 | } |
| 1646 | |
| 1647 | if (vxlan_sockaddr_supported(&sc->vxl_dst_addr, 0) == 0) { |
| 1648 | reason = "destination address type is not supported"; |
| 1649 | goto fail; |
| 1650 | } |
| 1651 | |
| 1652 | if (vxlan_sockaddr_in_any(&sc->vxl_dst_addr) != 0) { |
| 1653 | reason = "no valid destination address specified"; |
| 1654 | goto fail; |
| 1655 | } |
| 1656 | |
| 1657 | if (vxlan_sockaddr_in_multicast(&sc->vxl_dst_addr) == 0 && |
| 1658 | sc->vxl_mc_ifname[0] != '\0') { |
| 1659 | reason = "can only specify interface with a group address"; |
| 1660 | goto fail; |
| 1661 | } |
| 1662 | |
| 1663 | if (vxlan_sockaddr_in_any(&sc->vxl_src_addr) == 0) { |
| 1664 | if (VXLAN_SOCKADDR_IS_IPV4(&sc->vxl_src_addr) ^ |
| 1665 | VXLAN_SOCKADDR_IS_IPV4(&sc->vxl_dst_addr)) { |
| 1666 | reason = "source and destination address must both " |
| 1667 | "be either IPv4 or IPv6"; |
| 1668 | goto fail; |
| 1669 | } |
| 1670 | } |
| 1671 | |
| 1672 | if (sc->vxl_src_addr.in4.sin_port == 0) { |
| 1673 | reason = "local port not specified"; |
| 1674 | goto fail; |
| 1675 | } |
| 1676 | |
| 1677 | if (sc->vxl_dst_addr.in4.sin_port == 0) { |
| 1678 | reason = "remote port not specified"; |
| 1679 | goto fail; |
| 1680 | } |
| 1681 | |
| 1682 | return (0); |
| 1683 | |
| 1684 | fail: |
| 1685 | if_printf(sc->vxl_ifp, "cannot initialize interface: %s\n", reason); |
| 1686 | return (EINVAL); |
| 1687 | } |
| 1688 | |
| 1689 | static void |
no test coverage detected