aboutsummaryrefslogtreecommitdiff
path: root/src/openvpn/mroute.c
diff options
context:
space:
mode:
authorGert Doering2014-01-10 17:25:42 +0100
committerGert Doering2014-01-11 12:38:33 +0100
commit432ca2b8f15e4bb4d6fcf72b4b48b1a371247e7b (patch)
treeab36056b3ce2a034eba3cf095c29e7e960b935f0 /src/openvpn/mroute.c
parent672943fbef58c444913a6d378fbd532f9a0c8605 (diff)
downloadopenvpn-432ca2b8f15e4bb4d6fcf72b4b48b1a371247e7b.zip
openvpn-432ca2b8f15e4bb4d6fcf72b4b48b1a371247e7b.tar.gz
Cleanup ir6->netbits handling.
Get rid of all "if (ir6->netbits>=0)" checks, as those are always true (unlike ir->netbits for IPv4, we don't do the special case for "if it's a host, put -1 in there" for IPv6). Merge mroute_helper_{add,del}_iroute and mroute_helper_{add,del}_iroute6 into unified mroute_helper_{add,del}_iroute46() function as they did the same thing anyway, just with slightly different parameters. Make Arne happy. Signed-off-by: Gert Doering <gert@greenie.muc.de> Acked-by: Arne Schwabe <arne@rfc2549.org> Message-Id: <1389371142-26705-2-git-send-email-gert@greenie.muc.de> URL: http://article.gmane.org/gmane.network.openvpn.devel/8198
Diffstat (limited to 'src/openvpn/mroute.c')
-rw-r--r--src/openvpn/mroute.c56
1 files changed, 11 insertions, 45 deletions
diff --git a/src/openvpn/mroute.c b/src/openvpn/mroute.c
index 850e336..ba4ef46 100644
--- a/src/openvpn/mroute.c
+++ b/src/openvpn/mroute.c
@@ -487,62 +487,28 @@ mroute_helper_regenerate (struct mroute_helper *mh)
}
void
-mroute_helper_add_iroute (struct mroute_helper *mh, const struct iroute *ir)
+mroute_helper_add_iroute46 (struct mroute_helper *mh, int netbits)
{
- if (ir->netbits >= 0)
+ if (netbits >= 0)
{
- ASSERT (ir->netbits < MR_HELPER_NET_LEN);
+ ASSERT (netbits < MR_HELPER_NET_LEN);
++mh->cache_generation;
- ++mh->net_len_refcount[ir->netbits];
- if (mh->net_len_refcount[ir->netbits] == 1)
+ ++mh->net_len_refcount[netbits];
+ if (mh->net_len_refcount[netbits] == 1)
mroute_helper_regenerate (mh);
}
}
void
-mroute_helper_del_iroute (struct mroute_helper *mh, const struct iroute *ir)
+mroute_helper_del_iroute46 (struct mroute_helper *mh, int netbits)
{
- if (ir->netbits >= 0)
+ if (netbits >= 0)
{
- ASSERT (ir->netbits < MR_HELPER_NET_LEN);
+ ASSERT (netbits < MR_HELPER_NET_LEN);
++mh->cache_generation;
- --mh->net_len_refcount[ir->netbits];
- ASSERT (mh->net_len_refcount[ir->netbits] >= 0);
- if (!mh->net_len_refcount[ir->netbits])
- mroute_helper_regenerate (mh);
- }
-}
-
-/* this is a bit inelegant, we really should have a helper to that
- * is only passed the netbits value, and not the whole struct iroute *
- * - thus one helper could do IPv4 and IPv6. For the sake of "not change
- * code unrelated to IPv4" this is left for later cleanup, for now.
- */
-void
-mroute_helper_add_iroute6 (struct mroute_helper *mh,
- const struct iroute_ipv6 *ir6)
-{
- if (ir6->netbits >= 0)
- {
- ASSERT (ir6->netbits < MR_HELPER_NET_LEN);
- ++mh->cache_generation;
- ++mh->net_len_refcount[ir6->netbits];
- if (mh->net_len_refcount[ir6->netbits] == 1)
- mroute_helper_regenerate (mh);
- }
-}
-
-void
-mroute_helper_del_iroute6 (struct mroute_helper *mh,
- const struct iroute_ipv6 *ir6)
-{
- if (ir6->netbits >= 0)
- {
- ASSERT (ir6->netbits < MR_HELPER_NET_LEN);
- ++mh->cache_generation;
- --mh->net_len_refcount[ir6->netbits];
- ASSERT (mh->net_len_refcount[ir6->netbits] >= 0);
- if (!mh->net_len_refcount[ir6->netbits])
+ --mh->net_len_refcount[netbits];
+ ASSERT (mh->net_len_refcount[netbits] >= 0);
+ if (!mh->net_len_refcount[netbits])
mroute_helper_regenerate (mh);
}
}