staticint ovpn_mp_alloc(struct ovpn_priv *ovpn)
{ struct in_device *dev_v4; int i;
if (ovpn->mode != OVPN_MODE_MP) return 0;
dev_v4 = __in_dev_get_rtnl(ovpn->dev); if (dev_v4) { /* disable redirects as Linux gets confused by ovpn * handling same-LAN routing. * This happens because a multipeer interface is used as * relay point between hosts in the same subnet, while * in a classic LAN this would not be needed because the * two hosts would be able to talk directly.
*/
IN_DEV_CONF_SET(dev_v4, SEND_REDIRECTS, false);
IPV4_DEVCONF_ALL(dev_net(ovpn->dev), SEND_REDIRECTS) = false;
}
/* the peer container is fairly large, therefore we allocate it only in * MP mode
*/
ovpn->peers = kzalloc(sizeof(*ovpn->peers), GFP_KERNEL); if (!ovpn->peers) return -ENOMEM;
for (i = 0; i < ARRAY_SIZE(ovpn->peers->by_id); i++) {
INIT_HLIST_HEAD(&ovpn->peers->by_id[i]);
INIT_HLIST_NULLS_HEAD(&ovpn->peers->by_vpn_addr4[i], i);
INIT_HLIST_NULLS_HEAD(&ovpn->peers->by_vpn_addr6[i], i);
INIT_HLIST_NULLS_HEAD(&ovpn->peers->by_transp_addr[i], i);
}
/** * ovpn_dev_is_valid - check if the netdevice is of type 'ovpn' * @dev: the interface to check * * Return: whether the netdevice is of type 'ovpn'
*/ bool ovpn_dev_is_valid(conststruct net_device *dev)
{ return dev->netdev_ops == &ovpn_netdev_ops;
}
dev->type = ARPHRD_NONE;
dev->flags = IFF_POINTOPOINT | IFF_NOARP;
dev->priv_flags |= IFF_NO_QUEUE; /* when routing packets to a LAN behind a client, we rely on the * route entry that originally brought the packet into ovpn, so * don't release it
*/
netif_keep_dst(dev);
/* Set carrier explicitly after registration, this way state is * clearly defined. * * In case of MP interfaces we keep the carrier always on. * * Carrier for P2P interfaces is initially off and it is then * switched on and off when the remote peer is added or deleted.
*/ if (ovpn->mode == OVPN_MODE_MP)
netif_carrier_on(dev); else
netif_carrier_off(dev);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.