From 345108234ee2d6d947417bc242354dd68c70fa72 Mon Sep 17 00:00:00 2001
From: Erwan Martin <public@fzwte.net>
Date: Tue, 10 Nov 2015 11:50:24 +0100
Subject: [PATCH] Delete routes to addresses that come from the local
interface.
When receiving a packet on the TUN/TAP interface, check that the source address is not in the routing table. If it is, that means that the address moved from the network of a client to the network of the server, and thus its route should be deleted.
Signed-off-by: Erwan Martin <public@fzwte.net>
---
src/openvpn/multi.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index 7c3aaac..765ff00 100644
a
|
b
|
multi_process_incoming_tun (struct multi_context *m, const unsigned int mpp_flag |
2626 | 2626 | } |
2627 | 2627 | else |
2628 | 2628 | { |
| 2629 | struct hash_element *he; |
| 2630 | const uint32_t hv = hash_value (m->vhash, &src); |
| 2631 | struct hash_bucket *bucket = hash_bucket (m->vhash, hv); |
| 2632 | he = hash_lookup_fast (m->vhash, bucket, &src, hv); |
| 2633 | if (he) { |
| 2634 | /* the packet comes from the local interface, but a route exists for its source address -> delete it */ |
| 2635 | struct multi_route *bad_route = (struct multi_route *) he->value; |
| 2636 | hash_remove_fast (m->vhash, bucket, &src, hv); |
| 2637 | multi_route_del (bad_route); |
| 2638 | |
| 2639 | msg (D_MULTI_LOW, "MULTI: Learn: %s -> local interface", |
| 2640 | mroute_addr_print (&src, &gc)); |
| 2641 | } |
| 2642 | |
2629 | 2643 | multi_set_pending (m, multi_get_instance_by_virtual_addr (m, &dest, dev_type == DEV_TYPE_TUN)); |
2630 | 2644 | |
2631 | 2645 | if (m->pending) |