[linux-vrf-core] More patches
Status: Beta
Brought to you by:
jleu
From: Jorge B. [DTI2] <jo...@dt...> - 2002-10-25 17:04:42
|
Hi James, More patches here and more on the way... BTW My setup is working wonderfully :) - Patch to netkit-telnet-0.17 (I myself use debian too), added support to tell what VRF we want to use, usefull to test and configure routers ;) - Patch to kernel to add a SIOCGETVRF, yes I know it's a hack but I like to known what VRFs exists. Best regards, -Jorge ============================================================== Jorge Boncompte - Tecnico de sistemas DTI2 - Desarrollo de la Tecnologia de las Comunicaciones -------------------------------------------------------------- C/ Abogado Enriquez Barrios, 5 14004 CORDOBA (SPAIN) Tlf: +34 957 761395 / FAX: +34 957 450380 -------------------------------------------------------------- jo...@dt... _-_-_-_-_-_-_-_-_-_-_-_-_-_ http://www.dti2.net ============================================================== - Sin pistachos no hay Rock & Roll... - Without wicker a basket cannot be done. ============================================================== diff -uNr netkit-telnet-0.17/telnet/commands.cc netkit-telnet-0.17-jorge/telnet/commands.cc --- netkit-telnet-0.17/telnet/commands.cc Fri Oct 25 18:36:18 2002 +++ netkit-telnet-0.17-jorge/telnet/commands.cc Fri Oct 25 18:00:18 2002 @@ -89,6 +89,7 @@ #if defined(HAS_IPPROTO_IP) && defined(IP_TOS) int tos = -1; #endif /* defined(HAS_IPPROTO_IP) && defined(IP_TOS) */ +int vrf = -1; static unsigned long sourceroute(char *arg, char **cpp, int *lenp); @@ -1786,7 +1787,7 @@ NI_NUMERICHOST | NI_NUMERICSERV); printf("Trying %s...\n", name); - x = nlink.connect(debug, tmpaddr, srp, srlen, tos); + x = nlink.connect(debug, tmpaddr, srp, srlen, tos, vrf); if (!x) goto err; else if (x==1) diff -uNr netkit-telnet-0.17/telnet/main.cc netkit-telnet-0.17-jorge/telnet/main.cc --- netkit-telnet-0.17/telnet/main.cc Fri Oct 25 18:36:18 2002 +++ netkit-telnet-0.17-jorge/telnet/main.cc Fri Oct 25 18:31:22 2002 @@ -84,7 +84,7 @@ fprintf(stderr, "Usage: %s %s%s%s%s\n", prompt, "[-4] [-6] [-8] [-E] [-L] [-a] [-d] [-e char] [-l user]", - "\n\t[-n tracefile]", + "\n\t[-n tracefile] [-Z vrf]", #ifdef TN3270 "\n\t" "[-noasynch] [-noasynctty] [-noasyncnet] [-r] [-t transcom]\n\t", @@ -108,7 +108,7 @@ int ch; char *user; int family; - + tninit(); /* Clear out things */ #if defined(CRAY) && !defined(__STDC__) _setlist_init(); /* Work around compiler bug */ @@ -127,7 +127,7 @@ rlogin = (strncmp(prompt, "rlog", 4) == 0) ? '~' : _POSIX_VDISABLE; autologin = -1; - while ((ch = getopt(argc, argv, "468EKLS:X:ade:k:l:n:rt:x")) != EOF) { + while ((ch = getopt(argc, argv, "468EKLS:X:Z:ade:k:l:n:rt:x")) != EOF) { switch(ch) { case '4': family = AF_INET; @@ -173,6 +173,14 @@ break; case 'X': // disable authentication type "optarg" + break; + case 'Z': + extern int vrf; + vrf = strtol(optarg, 0, 0); + if (vrf < 1 || vrf > 255) { + printf("vrf %u out of range\n", vrf); + exit(1); + } break; case 'a': autologin = 1; Binary files netkit-telnet-0.17/telnet/main.o and netkit-telnet-0.17-jorge/telnet/main.o differ diff -uNr netkit-telnet-0.17/telnet/netlink.cc netkit-telnet-0.17-jorge/telnet/netlink.cc --- netkit-telnet-0.17/telnet/netlink.cc Fri Oct 25 18:36:18 2002 +++ netkit-telnet-0.17-jorge/telnet/netlink.cc Fri Oct 25 18:08:39 2002 @@ -82,7 +82,7 @@ } int netlink::connect(int debug, struct addrinfo *addr, - char *srcroute, int srlen, int tos) + char *srcroute, int srlen, int tos, int vrf) { int on=1; @@ -117,6 +117,10 @@ if (debug && setsockopt(net, SOL_SOCKET, SO_DEBUG, &on, sizeof(on)) < 0) { perror("setsockopt (SO_DEBUG)"); + } + + if (vrf && setsockopt(net, SOL_SOCKET, SO_VRF, (char *)&vrf, sizeof(vrf)) < 0) { + perror("setsockopt (SO_VRF)"); } if (::connect(net, addr->ai_addr, addr->ai_addrlen) < 0) { diff -uNr netkit-telnet-0.17/telnet/netlink.h netkit-telnet-0.17-jorge/telnet/netlink.h --- netkit-telnet-0.17/telnet/netlink.h Fri Oct 25 18:36:18 2002 +++ netkit-telnet-0.17-jorge/telnet/netlink.h Fri Oct 25 17:57:02 2002 @@ -8,7 +8,7 @@ int connect(int debug, struct addrinfo *hostaddr, char *srcroute, int srlen, - int tos); + int tos, int vrf); void close(int doshutdown); int setdebug(int debug); diff -uNr linux-2.4.20pre11/include/linux/sockios.h linux-2.4.20pre11-jorge/include/linux/sockios.h --- linux-2.4.20pre11/include/linux/sockios.h Fri Oct 18 19:52:15 2002 +++ linux-2.4.20pre11-jorge/include/linux/sockios.h Wed Oct 23 17:30:50 2002 @@ -110,6 +110,7 @@ #define SIOCADDVRF 0x8986 /* add VRF */ #define SIOCDELVRF 0x8987 /* del VRF */ +#define SIOCGETVRF 0x8988 /* get VRF */ /* bonding calls */ diff -uNr linux-2.4.20pre11/net/ipv4/af_inet.c linux-2.4.20pre11-jorge/net/ipv4/af_inet.c --- linux-2.4.20pre11/net/ipv4/af_inet.c Fri Oct 18 19:52:15 2002 +++ linux-2.4.20pre11-jorge/net/ipv4/af_inet.c Wed Oct 23 18:06:54 2002 @@ -132,6 +132,7 @@ extern void ip_mc_drop_socket(struct sock *sk); extern int fib_add_vrf(unsigned char vrf); extern int fib_del_vrf(unsigned char vrf); +extern int fib_get_vrf(unsigned char vrf); #ifdef CONFIG_DLCI extern int dlci_ioctl(unsigned int, void*); @@ -935,6 +936,12 @@ case SIOCDELVRF: lock_kernel(); err = fib_del_vrf((unsigned char)arg); + unlock_kernel(); + return err; + + case SIOCGETVRF: + lock_kernel(); + err = fib_get_vrf((unsigned char)arg); unlock_kernel(); return err; diff -uNr linux-2.4.20pre11/net/ipv4/fib_rules.c linux-2.4.20pre11-jorge/net/ipv4/fib_rules.c --- linux-2.4.20pre11/net/ipv4/fib_rules.c Fri Oct 18 19:52:15 2002 +++ linux-2.4.20pre11-jorge/net/ipv4/fib_rules.c Wed Oct 23 19:24:30 2002 @@ -476,6 +490,18 @@ write_unlock_bh(&fib_rules_lock[vrf]); + return 0; +} + +int fib_get_vrf(unsigned char vrf) { + + if (vrf < 0 || vrf > VRF_MAX) { + return -EBADF; + } + if (!fib_rules[vrf]) { + return -ENOENT; + } + return 0; } |