Ejemplo n.º 1
0
static int vrf_rtable_create(struct net_device *dev)
{
	struct net_vrf *vrf = netdev_priv(dev);
	struct rtable *rth, *rth_local;

	if (!fib_new_table(dev_net(dev), vrf->tb_id))
		return -ENOMEM;

	/* create a dst for routing packets out through a VRF device */
	rth = rt_dst_alloc(dev, 0, RTN_UNICAST, 1, 1, 0);
	if (!rth)
		return -ENOMEM;

	/* create a dst for local ingress routing - packets sent locally
	 * to local address via the VRF device as a loopback
	 */
	rth_local = rt_dst_alloc(dev, RTCF_LOCAL, RTN_LOCAL, 1, 1, 0);
	if (!rth_local) {
		dst_release(&rth->dst);
		return -ENOMEM;
	}

	rth->dst.output	= vrf_output;
	rth->rt_table_id = vrf->tb_id;

	rth_local->rt_table_id = vrf->tb_id;

	rcu_assign_pointer(vrf->rth, rth);
	rcu_assign_pointer(vrf->rth_local, rth_local);

	return 0;
}
Ejemplo n.º 2
0
static int vrf_rtable_create(struct net_device *dev)
{
	struct net_vrf *vrf = netdev_priv(dev);
	struct rtable *rth;

	if (!fib_new_table(dev_net(dev), vrf->tb_id))
		return -ENOMEM;

	rth = rt_dst_alloc(dev, 0, RTN_UNICAST, 1, 1, 0);
	if (!rth)
		return -ENOMEM;

	rth->dst.output = vrf_output;
	rth->rt_table_id = vrf->tb_id;

	rcu_assign_pointer(vrf->rth, rth);

	return 0;
}