[mpls-linux-general] Re: MPLS + VRF
Status: Beta
Brought to you by:
jleu
|
From: James R. L. <jl...@mi...> - 2004-10-04 16:42:02
|
On Mon, Oct 04, 2004 at 09:54:54AM +0000, Massimo Magnani wrote:
> Hi James, I am Massimo Magnani from Italy, and I am testing linux MPLS
> and VRF.
>
> First of all, sorry if I mail you directly.
That is ok. I would prefer you contact me via the mailing list, but that
is just so that others can see what you're working on.
(I've CC'ed the lists)
I plan on creating a development tree which will contain the latest MPLS, VRF,
and L2CC code. I will probably be releasing this as a seperate RPM and
patch.
I the mean time, change mpls4_nexthop_resolve() to look like this:
static int mpls4_nexthop_resolve(struct neighbour **np, struct sockaddr *sock_addr, int oif)
{
struct sockaddr_in *addr = (struct sockaddr_in *) sock_addr;
u32 saddr = addr->sin_addr.s_addr;
struct flowi fl = { .oif = oif,
.nl_u = { .ip4_u = { .daddr = saddr } } };
struct rtable *rp;
unsigned char vrf = 0;
int err;
if (addr->sin_family != AF_INET)
return -EINVAL;
if ((dev = dev_get_by_index(oif)))
vrf = dev->vrf;
if (inet_addr_type(vrf, saddr) != RTN_UNICAST)
return -EINVAL;
fl.vrf = vrf;
err = __ip_route_output_key(&rp, &fl);
if (err)
return err;
/* If routing cache stops to automatically bind output routes
* to ARP cache, we will have to make arp_bind_neighbour() ourselves.
*/
if (!rp->u.dst.neighbour)
BUG();
*np = neigh_clone(rp->u.dst.neighbour);
ip_rt_put(rp);
return err;
}
Even with the above hack, you will lack the ability to map traffic from an
LSP into a VRF. For that you will need to implement an 'instruction'. Look
in linux/net/mpls/mpls_opcode.c for examples. The new instruction will
need to set the 'vrf' field on a skb.
> I patched my kernel 2.6.8.1 with your mpls patch and everything has been
> working fine. Then I read that you also have written some code to
> implement VRF on linux, so I wanted to test this functionality too.
>
> I patched my kernel again, and I had a compilation problem with mpls4.c,
> maybe because in include/net/route.h the struct inet_addr_type now has
> also a vrf 'field' (sorry but I don't know almost anything about C
> programming...)
>
> I modified the mpls4.c file - I added a 'unsigned char vrf' in line 289
> 'static int mpls4_nexthop_resolve(struct neighbour **np, struct sockaddr
> *sock_addr, int oif, unsigned char vrf), and in line 303 if
> (inet_add_type(vrf, saddr) != RTN_UNICAST) - and now I can compile the
> kernel again.
>
> I don't know if these two modifications are correct, and moreover, I
> think that I could fill the vrf variable with some value, but I don't
> know where to take that value!
>
> I mean I think I should have a vrf = something, but I don't know what
> 'something' is!
>
> Thank you in advance, sorry to have bothered you.
>
> Best regards.
>
> Massimo Magnani
--
James R. Leu
jl...@mi...
|