[Xorp-hackers] linux VRRP svn xorp

Eric S. Johnson esj at cs.fiu.edu
Sat Mar 20 06:13:43 PDT 2010


>Seems to me that if we put a second IP on the interface, then we
>can let the OS deal with arp and kill the arpd logic entirely.

Yeah, I thought the same thing. In fact it looks like the pseudo arp
deamon wont "start up" for IP's assigned to the interface, due to 
the Vrrp::check_ownership 

>> Would a correct solution be to have xorp set the virtual IP
>> as a secondary IP on that VIF? If so, what would be the correct
>> way to do this.. IfTreeVif::add_addr method?
>
>Sounds good to me.  I fixed the bug in xorp.ct that caused vrrp
>to crash early...now I'm seeing similar activity w/regard to
>the MAC addr being set but no IP visible.
>
>I'll poke at the add_addr logic and see what I can get
>to happen...

Ive been on vacation this last week, but started this before 
I left. Below are the diff I have. Basicly I copied the logic 
for adding the mac, and got as far as vrrp_target where I think
a XRL needs to be sent, but I hadn't figured out how/what yet,

E


--
diff -ur ../../xorp-svn-20100217.orig/vrrp/vrrp.cc ./vrrp.cc
--- ../../xorp-svn-20100217.orig/vrrp/vrrp.cc	2010-02-17 10:25:11.000000000 -0500
+++ ./vrrp.cc	2010-03-11 17:14:50.000000000 -0500
@@ -125,9 +125,11 @@
 void
 Vrrp::add_ip(const IPv4& ip)
 {
+XLOG_WARNING("ESJ in Vrrp::add_ip before _ips.insert ip=%s\n",ip.str().c_str());
     _ips.insert(ip);
-
+XLOG_WARNING("ESJ in Vrrp::add_ip after _ips.insert\n");
     check_ownership();
+XLOG_WARNING("ESJ in Vrrp::add_ip after check_ownership()\n");
 }
 
 void
@@ -198,6 +200,27 @@
     setup_intervals();
 }
 
+//ESJ
+void
+Vrrp::add_ips_to_vif()
+{
+    for (IPS::iterator i = _ips.begin(); i != _ips.end(); ++i) {
+        const IPv4& ip = *i;
+	XLOG_INFO ("ESJ adding %s as ip on virtual interface\n", ip.str().c_str() );
+	_vif.add_ip (ip);
+    }
+}
+
+void
+Vrrp::del_ips_from_vif()
+{
+    for (IPS::iterator i = _ips.begin(); i != _ips.end(); ++i) {
+        const IPv4& ip = *i;
+	XLOG_INFO ("ESJ deleting %s as ip on virtual interface\n", ip.str().c_str() );
+	_vif.add_ip (ip);
+    }
+}
+
 uint32_t
 Vrrp::priority() const
 {
@@ -229,6 +252,7 @@
 {
     _state = MASTER;
 
+    add_ips_to_vif();
     _vif.add_mac(_source_mac);
     send_advertisement();
     send_arps();
@@ -240,6 +264,7 @@
 Vrrp::become_backup()
 {
     if (_state == MASTER) {
+        del_ips_from_vif();
 	_vif.delete_mac(_source_mac);
 	_arpd.stop();
     }
diff -ur ../../xorp-svn-20100217.orig/vrrp/vrrp.hh ./vrrp.hh
--- ../../xorp-svn-20100217.orig/vrrp/vrrp.hh	2010-02-17 10:25:11.000000000 -0500
+++ ./vrrp.hh	2010-03-11 17:12:24.000000000 -0500
@@ -264,6 +264,16 @@
     void recv_advertisement(const IPv4& from, uint32_t priority);
 
     /**
+     * ESJ add ip to vif, used to add virtual IPs to vif when master
+     */
+    void add_ips_to_vif();
+
+    /**
+     * ESJ delete ip from vif, used to delete virtual IPs from vif when not master
+     */
+    void del_ips_from_vif();
+
+    /**
      * Check whether the IPs in the VRRP packet match those configured
      *
      * @return true on exact matches.
diff -ur ../../xorp-svn-20100217.orig/vrrp/vrrp_interface.hh ./vrrp_interface.hh
--- ../../xorp-svn-20100217.orig/vrrp/vrrp_interface.hh	2010-02-17 10:25:11.000000000 -0500
+++ ./vrrp_interface.hh	2010-03-11 17:24:37.000000000 -0500
@@ -85,6 +85,20 @@
      */
     virtual void	    leave_mcast() = 0;
 
+    /** ESJ
+     * Add a IP address to this interface.
+     *
+     * @param mac IP address to add.
+     */
+    virtual void	    add_ip(const IPv4& ip) = 0;
+
+    /**
+     * Delete a IP address from this interface.
+     *
+     * @param mac IP address to delete from this interface.
+     */
+    virtual void	    delete_ip(const IPv4& ip) = 0;
+
     /**
      * Add a MAC address to this interface.
      *
diff -ur ../../xorp-svn-20100217.orig/vrrp/vrrp_target.cc ./vrrp_target.cc
--- ../../xorp-svn-20100217.orig/vrrp/vrrp_target.cc	2010-02-17 10:25:11.000000000 -0500
+++ ./vrrp_target.cc	2010-03-11 17:43:20.000000000 -0500
@@ -332,6 +332,21 @@
     _xrls_pending++;
 }
 
+//ESJ
+void
+VrrpTarget::add_ip(const string& ifname, const IPv4& ip)
+{
+	XLOG_INFO("ESJ - nothing yet %s %s \n",ifname.c_str(), ip.str().c_str() );
+}
+
+void
+VrrpTarget::del_ip(const string& ifname, const IPv4& ip)
+{
+	XLOG_INFO("ESJ - nothing yet %s %s \n",ifname.c_str(), ip.str().c_str() );
+}
+
+
+
 void
 VrrpTarget::add_mac(const string& ifname, const Mac& mac)
 {
diff -ur ../../xorp-svn-20100217.orig/vrrp/vrrp_target.hh ./vrrp_target.hh
--- ../../xorp-svn-20100217.orig/vrrp/vrrp_target.hh	2010-02-17 10:25:11.000000000 -0500
+++ ./vrrp_target.hh	2010-03-11 17:36:48.000000000 -0500
@@ -112,6 +112,22 @@
      */
     void       stop_arps(const string& ifname, const string& vifname);
 
+    /** ESJ
+     * add a IP address to the router.
+     *
+     * @param ifname the interface on which to add the ip.
+     * @param ip the ip address.
+     */
+    void       add_ip(const string& ifname, const IPv4& ip);
+
+    /** ESJ
+     * del a IP address to the router.
+     *
+     * @param ifname the interface on which to add the ip.
+     * @param ip the ip address.
+     */
+    void       del_ip(const string& ifname, const IPv4& ip);
+
     /**
      * Add a MAC address to the router.
      *
diff -ur ../../xorp-svn-20100217.orig/vrrp/vrrp_vif.cc ./vrrp_vif.cc
--- ../../xorp-svn-20100217.orig/vrrp/vrrp_vif.cc	2010-02-17 10:25:11.000000000 -0500
+++ ./vrrp_vif.cc	2010-03-12 12:10:24.000000000 -0500
@@ -258,6 +258,22 @@
     }
 }
 
+//ESJ
+void
+VrrpVif::add_ip(const IPv4& ip)
+{
+	XLOG_ASSERT(_ifname == _vifname);
+	_vt.add_ip(_vifname,ip);
+}
+
+void
+VrrpVif::delete_ip(const IPv4& ip)
+{
+	XLOG_ASSERT(_ifname == _vifname);
+	_vt.del_ip(_vifname,ip);
+}
+
+
 void
 VrrpVif::add_mac(const Mac& mac)
 {
diff -ur ../../xorp-svn-20100217.orig/vrrp/vrrp_vif.hh ./vrrp_vif.hh
--- ../../xorp-svn-20100217.orig/vrrp/vrrp_vif.hh	2010-02-17 10:25:11.000000000 -0500
+++ ./vrrp_vif.hh	2010-03-11 17:18:18.000000000 -0500
@@ -132,6 +132,20 @@
      */
     void	    recv(const IPv4& from, const PAYLOAD& payload);
 
+    /** ESJ
+     * Add a IP address to this interface.
+     *
+     * @param IPv4 IP address to add.
+     */
+    void	    add_ip(const IPv4& ip); 
+
+    /**
+     * Delete a IP address from this interface.
+     *
+     * @param IPv4 IP address to remove.
+     */
+    void	    delete_ip(const IPv4& ip);
+
     /**
      * Add a MAC address to this interface.
      *



More information about the Xorp-hackers mailing list