--- Begin Message ---
Package: vrrpd
Version: 0.7
Severity: important
Tags: patch
Summary:
Current versions of vrrpd do not allow prefix length specidication
in command line, which make the virtual IP is inserted with as /32
and may cause routing issues.
Explanation:
This is a problem for some configurations for which good prefix or
broadcast information is necessary for the interface to be handled
correctly (OSPF for example).
$ vrrpd -v 3 -i eth1.3 80.67.169.1 &
$ ip addr list dev eth1.3
8: eth1.3: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue
link/ether 00:00:5e:00:01:03 brd ff:ff:ff:ff:ff:ff
inet 80.67.161.2/25 brd 80.67.161.127 scope global eth1.3
inet 80.67.169.1/32 scope global eth1.3
and with the patch you may request :
$ vrrpd -i 3 -i eth1.3 80.67.169.1/25 &
$ ip addr list dev eth1.3
8: eth1.3: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue
link/ether 00:00:5e:00:01:03 brd ff:ff:ff:ff:ff:ff
inet 80.67.161.2/25 brd 80.67.161.127 scope global eth1.3
inet 80.67.169.1/25 brd 80.67.169.127 scope global eth1.3
This might be very important because prefix length makes the
IP belong to a network or another, and OSPF for example will not
use an interface if its netmask does not match exactly that of
a network it handles (which may make the network not to be
annonunced anymore).
Modifications:
Very few modifications had to be done
- store the prefix length information along with IP address in
the virtual servers list
- read optional /n at end of virtual IP in command line
- add prefix length and broadcast address to netlink ipaddr call
Please find patch attached (diff -Naur).
Regards,
lulu
diff -Naur vrrpd-0.7.1/Changes vrrpd-0.7.1-pfxlen/Changes
--- vrrpd-0.7.1/Changes 2002-02-04 05:29:32.000000000 +0100
+++ vrrpd-0.7.1-pfxlen/Changes 2004-02-29 09:57:29.000000000 +0100
@@ -1,3 +1,8 @@
+0.7 - February 28th 2004
+- Sylvain Vallerot : Added support for ip/prefix specification in command line.
+
+ Modified files: Changes vrrpd.c vrrpd.h ipaddr.c ipaddr.h
+
0.7 - February 4th 2002
- David Hunter : Added monitored interface routines and definitions. These will
only work for drivers that implement the MII calls. Two new
diff -Naur vrrpd-0.7.1/ipaddr.c vrrpd-0.7.1-pfxlen/ipaddr.c
--- vrrpd-0.7.1/ipaddr.c 2001-07-18 10:10:02.000000000 +0200
+++ vrrpd-0.7.1-pfxlen/ipaddr.c 2004-02-28 22:00:46.000000000 +0100
@@ -123,7 +123,7 @@
AIM : add or remove
REMARK :
****************************************************************/
-int ipaddr_op( int ifindex, uint32_t addr, int addF )
+int ipaddr_op( int ifindex, uint32_t addr, uint8_t length, int addF )
{
struct rtnl_handle rth;
struct {
@@ -131,6 +131,8 @@
struct ifaddrmsg ifa;
char buf[256];
} req;
+ uint32_t bcast;
+
memset(&req, 0, sizeof(req));
req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg));
@@ -138,11 +140,14 @@
req.n.nlmsg_type = addF ? RTM_NEWADDR : RTM_DELADDR;
req.ifa.ifa_family = AF_INET;
req.ifa.ifa_index = ifindex;
- req.ifa.ifa_prefixlen = 32;
+ req.ifa.ifa_prefixlen = length;
addr = htonl( addr );
addattr_l(&req.n, sizeof(req), IFA_LOCAL, &addr, sizeof(addr) );
+ bcast = addr | htonl((1 << (32 - length)) - 1);
+ addattr_l(&req.n, sizeof(req), IFA_BROADCAST, &bcast, sizeof(bcast) );
+
if (rtnl_open(&rth, 0) < 0)
return -1;
if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
diff -Naur vrrpd-0.7.1/ipaddr.h vrrpd-0.7.1-pfxlen/ipaddr.h
--- vrrpd-0.7.1/ipaddr.h 2001-05-23 23:13:44.000000000 +0200
+++ vrrpd-0.7.1-pfxlen/ipaddr.h 2004-02-28 20:19:31.000000000 +0100
@@ -15,7 +15,7 @@
/*@$#[ipaddr.c] global proto. AutoProtoSigV1.1. date: 00/06/02 23:47:40 */
#include "proto.h"
int ipaddr_list PROTO((int ifindex, uint32_t *array, int max_elem));
-int ipaddr_op PROTO((int ifindex, uint32_t addr, int addF));
+int ipaddr_op PROTO((int ifindex, uint32_t addr, uint8_t length, int addF));
/*@$% end of AutoProtoSigV1.1 (Dont remove this line) []*/
diff -Naur vrrpd-0.7.1/vrrpd.c vrrpd-0.7.1-pfxlen/vrrpd.c
--- vrrpd-0.7.1/vrrpd.c 2004-02-28 20:11:40.000000000 +0100
+++ vrrpd-0.7.1-pfxlen/vrrpd.c 2004-02-29 09:54:46.000000000 +0100
@@ -11,8 +11,11 @@
* Contributor: Alexandre Cassen, <[email protected]>
* Contributor: David Hunter, <[email protected]>
* Contributor: Chao-Cheng Wu, <[email protected]>
+ * Contributor: Sylvain Vallerot <[email protected]>
*
* Changes:
+ * Sylvain Vallerot : 2004/02/28 :
+ * <+> Add support for ip/prefix specification.
* Chao-Cheng Wu : 2003/11/16 :
* Fix Change the position of the Backup Routing Table's codes
* to fix VRRPD always restore Routing Table to the
@@ -392,13 +395,14 @@
vip_addr *vadd = &vsrv->vaddr[i];
if( !addF && !vadd->deletable ) continue;
- if( ipaddr_op( ifidx , vadd->addr, addF)){
+ if( ipaddr_op( ifidx , vadd->addr, vadd->length, addF)){
err = 1;
vadd->deletable = 0;
in.s_addr = htonl(vadd->addr);
- VRRP_LOG(("cant %s the address %s to %s\n"
+ VRRP_LOG(("cant %s the address %s/%d to %s\n"
, addF ? "set" : "remove"
, inet_ntoa(in)
+ , vadd->length
, vsrv->vif.ifname));
}else{
vadd->deletable = 1;
@@ -954,7 +957,7 @@
static void usage( void )
{
fprintf( stderr, "vrrpd version %s\n", VRRPD_VERSION );
- fprintf( stderr, "Usage: vrrpd -i ifname -v vrid [-f piddir] [-s] [-a auth]
[-p prio] [-m ifname] [-c delta] [-nh] ipaddr\n" );
+ fprintf( stderr, "Usage: vrrpd -i ifname -v vrid [-f piddir] [-s] [-a auth]
[-p prio] [-m ifname] [-c delta] [-nh] ipaddr[/length]\n" );
fprintf( stderr, " -h : display this short inlined help\n" );
fprintf( stderr, " -n : Dont handle the virtual mac address\n" );
fprintf( stderr, " -i ifname: the interface name to run on\n" );
@@ -974,6 +977,7 @@
fprintf( stderr, " -c delta : Set the delta to decrease priority by (dfl:
%d)\n"
, VRRP_DELTA_DFL );
fprintf( stderr, " ipaddr : the ip address(es) of the virtual server\n" );
+ fprintf( stderr, " length : the length of the subnet mask\n" );
}
/****************************************************************
@@ -1149,7 +1153,7 @@
AIM :
REMARK :
****************************************************************/
-static void cfg_add_ipaddr( vrrp_rt *vsrv, uint32_t ipaddr )
+static void cfg_add_ipaddr( vrrp_rt *vsrv, uint32_t ipaddr, uint8_t length )
{
vsrv->naddr++;
/* alloc the room */
@@ -1162,6 +1166,7 @@
assert( vsrv->vaddr );
/* store the data */
vsrv->vaddr[vsrv->naddr-1].addr = ipaddr;
+ vsrv->vaddr[vsrv->naddr-1].length = length;
vsrv->vaddr[vsrv->naddr-1].deletable = 0;
}
@@ -1655,8 +1660,17 @@
}
/* add the virtual server ip */
for( ; argv[argc]; argc++ ){
+ char *slash = strchr(argv[argc], '/');
+ uint8_t length = 32;
+ if (slash) {
+ /* NULL the slash character */
+ *slash++ = 0;
+ /* retrieve prefix length */
+ length = (uint8_t)atoi(slash);
+ if ((length > 32) || (length < 0)) length = 32;
+ }
uint32_t ipaddr = inet_addr( argv[argc] );
- cfg_add_ipaddr( vsrv, ntohl(ipaddr) );
+ cfg_add_ipaddr( vsrv, ntohl(ipaddr), length );
}
/* check if the minimal configuration has been done */
if( chk_min_cfg( vsrv ) ){
diff -Naur vrrpd-0.7.1/vrrpd.h vrrpd-0.7.1-pfxlen/vrrpd.h
--- vrrpd-0.7.1/vrrpd.h 2002-02-04 04:58:36.000000000 +0100
+++ vrrpd-0.7.1-pfxlen/vrrpd.h 2004-02-28 20:28:18.000000000 +0100
@@ -83,6 +83,7 @@
typedef struct {
uint32_t addr; /* the ip address */
+ uint8_t length; /* the ip prefix length */
int deletable; /* TRUE if one of my primary addr */
} vip_addr;
--- End Message ---