Re: [linux-vrf-core] [PATCH] connected routes.
Status: Beta
Brought to you by:
jleu
From: James R. L. <jl...@mi...> - 2002-12-16 22:05:34
|
Applied (with formating changes) On Sun, Dec 15, 2002 at 07:39:36AM +0100, Yon Uriarte wrote: > Hi, > > When moving an interface to a new VRF the connected routes > stay on the old VRF and no connected routes are added to the > the new VRF. > > Somewhat brute force. This will work for any program changing > the dev->vrf, not just iproute2 with jorge's patch. > > c ya, > yon > > --- orig/net/core/dev.c Sun Dec 15 06:25:08 2002 > +++ local/net/core/dev.c Sun Dec 15 07:17:28 2002 > @@ -2016,8 +2016,28 @@ > return 0; > > case SIOCSIFVRF: /* Set the VRF for a device */ > - dev->vrf = ifr->ifr_flags; > - return 0; > + /* Quick and dirty way to get all routes changed > + automatically. In fact, it could be said that changing > + the VRF is somewhat equal to down'ing the interface > + (in the original VRF), and up'ing it in the new VRF. > + Another nice side effect is getting a netlink message > + (which could be generated via netdev_state_change()), > + so there is no need to poll to get VRF changes. > + Even adding a NETDEV_CHANGEVRF to the notifier events > + might be a more elegant solution. --yon */ > + > + if (dev->vrf != ifr->ifr_flags) > + { > + int flags = dev->flags; > + if (flags&IFF_UP) > + dev_change_flags (dev, flags^IFF_UP); > + > + dev->vrf = ifr->ifr_flags; > + > + if (flags&IFF_UP) > + dev_change_flags (dev, flags); > + } > + return 0; > > case SIOCGIFHWADDR: > memcpy(ifr->ifr_hwaddr.sa_data,dev->dev_addr, MAX_ADDR_LEN); -- James R. Leu |