Permalink
Browse files

Translator: remove all directly connected MRIB routes that conflict

with the unicast prefix of the translator. Fixes an RPF issue that
occurred when the same prefix was used locally on a real interface.
  • Loading branch information...
1 parent 72ae0c6 commit 7ff906a67b9408f5e8ee735e0155bd2c12849feb Teemu Kiviniemi committed Aug 15, 2011
Showing with 33 additions and 3 deletions.
  1. +9 −2 include/mrdpriv/linux/translator.h
  2. +24 −1 src/linux/translator.cpp
@@ -2,7 +2,7 @@
* Multicast Routing Daemon (MRD)
* translator.h - IPv4 to IPv6 multicast translator
*
- * Copyright (C) 2009, 2010 - Teemu Kiviniemi
+ * Copyright (C) 2009..2011 - Teemu Kiviniemi
* Copyright (C) 2009 - CSC - IT Center for Science Ltd.
* Copyright (C) 2006, 2007 - Hugo Santos
* Copyright (C) 2004..2006 - Universidade de Aveiro, IT Aveiro
@@ -42,7 +42,7 @@ class us_mfa;
/*!
* IPv4 to IPv6 multicast translator
*/
-class translator : public node, public icmp_handler {
+class translator : public node, public icmp_handler, public mrib_origin {
public:
translator(us_mfa *);
@@ -79,6 +79,13 @@ class translator : public node, public icmp_handler {
/* Set new MTU for a destination. */
void set_mtu(const in6_addr &, uint32_t);
+ /* Handle a new prefix in MRIB. */
+ void prefix_added(const inet6_addr &src, mrib_def::metric_def metric,
+ const mrib_def::prefix &prefix);
+
+ /* Required by mrib_origin, not used here. */
+ void return_prefix(mrib_def::prefix *);
+
private:
/* Receive incoming IPv4 packets */
View
@@ -2,7 +2,7 @@
* Multicast Routing Daemon (MRD)
* translator.cpp - IPv4 to IPv6 multicast translator
*
- * Copyright (C) 2009, 2010 - Teemu Kiviniemi
+ * Copyright (C) 2009..2011 - Teemu Kiviniemi
* Copyright (C) 2009 - CSC - IT Center for Science Ltd.
* Copyright (C) 2006, 2007 - Hugo Santos
* Copyright (C) 2004..2006 - Universidade de Aveiro, IT Aveiro
@@ -127,6 +127,9 @@ bool translator::check_startup() {
return false;
}
+ /* Listen for MRIB events. */
+ g_mrd->mrib().install_listener(this);
+
/* Add route to unicast prefix via the virtual interface. */
g_mrd->mrib().local().register_prefix(m_p_unicast_prefix->get_address(), m_virtual_interface);
@@ -871,3 +874,23 @@ uint16_t translator::ipv4_checksum(const uint8_t *buf, uint16_t len) const {
return checksum;
}
+
+/* Handle a new prefix in MRIB. */
+void translator::prefix_added(const inet6_addr &src, mrib_def::metric_def metric,
+ const mrib_def::prefix &prefix)
+{
+ if (prefix.metric == 0 &&
+ prefix.intf != m_virtual_interface &&
+ src == m_p_unicast_prefix->get_address()) {
+
+ if (should_log(EXTRADEBUG))
+ log().xprintf("Translator: Removing conflicting route %{Addr}.\n",
+ src);
+ g_mrd->mrib().local().unregister_prefix(src, prefix.intf);
+ }
+}
+
+/* Required by mrib_origin, not used here. */
+void translator::return_prefix(mrib_def::prefix *)
+{
+}

0 comments on commit 7ff906a

Please sign in to comment.