batman-adv gateway support
Hi,
batman-adv still lacks the well-known gateway functionality the batman daemon offered since quite a while. Since batman-adv works sufficiently well without it and due to the ongoing debate whether a layer 2 mesh protocol should interfere with layer 3 this topic has been neglected for a while. In multi-gateway environments proper gateway support is a must have. Therefore I hereby propose a set of patches to add this functionality. Comments welcome!
What you get:
* The first patch will add gateway announce / handling support to the protocol. You will have additional /proc files to switch gateway modes, get a list of gateways in the network and see the currently selected best gateway.
* The second patch simply adds batctl support to conveniently configure the gateway setup.
* The third patch checks whether locally received packets are DHCP queries and forwards them via uncicast to the best gateway instead of broadcasting them.
Note:
* These patches change the routing protocol, therefore the compat version is increased. This (intentionally) breaks interoperability with older batman-adv versions!
* Only DHCP traffic gets redirected to the best gateway - no other traffic is affected. This is part of the compromise we achieved during the last discussions.
* IPv6 support is still missing but should be fairly easy to add. Any volunteers ?
Regards,
Marek
PATCH 1/3 batman-adv: adding gateway functionality
Via the /proc filesystem you can change the gateway mode of a node to server or client (default is: off). Servers will announce there bandwidth, so that clients can choose their best gateway.
--- batman-adv-kernelland/Makefile.kbuild | 2 +- batman-adv-kernelland/gateway_client.c | 335 ++++++++++++++++++++++++++++++++ batman-adv-kernelland/gateway_client.h | 29 +++ batman-adv-kernelland/gateway_common.c | 276 ++++++++++++++++++++++++++ batman-adv-kernelland/gateway_common.h | 34 ++++ batman-adv-kernelland/main.c | 6 + batman-adv-kernelland/originator.c | 6 +- batman-adv-kernelland/packet.h | 4 +- batman-adv-kernelland/proc.c | 144 ++++++++++++++ batman-adv-kernelland/proc.h | 2 + batman-adv-kernelland/routing.c | 13 ++- batman-adv-kernelland/send.c | 3 + batman-adv-kernelland/types.h | 14 +- 13 files changed, 860 insertions(+), 8 deletions(-) create mode 100644 batman-adv-kernelland/gateway_client.c create mode 100644 batman-adv-kernelland/gateway_client.h create mode 100644 batman-adv-kernelland/gateway_common.c create mode 100644 batman-adv-kernelland/gateway_common.h
batman-adv-kernelland/Makefile.kbuild +1 -1
@@ -32,4 +32,4 @@ EXTRA_CFLAGS += -DREVISION_VERSION=\"r$(REVISION)\" endif obj-m += batman-adv.o -batman-adv-objs := main.o proc.o send.o routing.o soft-interface.o device.o translation-table.o bitarray.o hash.o ring_buffer.o vis.o hard-interface.o aggregation.o originator.o $(shell [ "2" -eq "$(VERSION)" ] && [ "6" -eq "$(PATCHLEVEL)" ] && [ "$(SUBLEVEL)" -le "28" ] && echo bat_printk.o) +batman-adv-objs := main.o proc.o send.o routing.o soft-interface.o device.o translation-table.o bitarray.o hash.o ring_buffer.o vis.o hard-interface.o aggregation.o originator.o gateway_common.o gateway_client.o $(shell [ "2" -eq "$(VERSION)" ] && [ "6" -eq "$(PATCHLEVEL)" ] && [ "$(SUBLEVEL)" -le "28" ] && echo bat_printk.o)
batman-adv-kernelland/gateway_client.c new file +335 -0
335 lines not on this page · raw message
batman-adv-kernelland/gateway_client.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Copyright (C) 2009 B.A.T.M.A.N. contributors: +* Marek Lindner +* This program is free software; you can redistribute it and/or +* modify it under the terms of version 2 of the GNU General Public +* License as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA +* +*/ + +extern atomic_t gw_clnt_class; + +void gw_deselect (void ); +void gw_election (void ); +void gw_check_election (struct orig_node *orig_node); +void gw_node_update (struct orig_node *orig_node,uint8_t new_gwflags); +void gw_node_delete (struct orig_node *orig_node); +void gw_node_purge_deleted (void ); +void gw_node_list_free (void ); +int gw_client_fill_buffer_text (unsigned char *buff,int buff_len);
batman-adv-kernelland/gateway_common.c new file +276 -0
276 lines not on this page · raw message
batman-adv-kernelland/gateway_common.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Copyright (C) 2009 B.A.T.M.A.N. contributors: +* Marek Lindner +* This program is free software; you can redistribute it and/or +* modify it under the terms of version 2 of the GNU General Public +* License as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA +* +*/ + +enum gw_modes { +GW_MODE_OFF , +GW_MODE_CLIENT , +GW_MODE_SERVER , +}; + +#define GW_MODE_OFF_NAME "off" +#define GW_MODE_CLIENT_NAME "client" +#define GW_MODE_SERVER_NAME "server" + +extern atomic_t gw_mode; +extern atomic_t gw_srv_class; + +void gw_srv_class_to_kbit (uint8_t gw_class,int *down,int *up); +ssize_t gw_mode_set (const char __user *userbuffer,size_t count);
batman-adv-kernelland/main.c +6 -0
@@ -28,6 +28,8 @@#include "device.h" #include "translation-table.h" #include "hard-interface.h" +#include "gateway_common.h" +#include "gateway_client.h" #include "types.h" #include "vis.h" #include "hash.h"
@@ -85,6 +87,9 @@ int init_module(void)atomic_set (&vis_interval,1000 );/* TODO: raise this later, this is only * for debugging now. */ atomic_set (&aggregation_enabled,1 ); +atomic_set (&gw_mode,GW_MODE_OFF ); +atomic_set (&gw_srv_class,0 ); +atomic_set (&gw_clnt_class,0 );/* the name should not be longer than 10 chars - see * http://lwn.net/Articles/23634/ */
@@ -191,6 +196,7 @@ void shutdown_module(void)/* TODO: unregister BATMAN pack */ +gw_node_list_free ();originator_free ();hna_local_free ();
batman-adv-kernelland/originator.c +5 -1
@@ -27,7 +27,7 @@#include "translation-table.h" #include "routing.h" #include "compat.h" - +#include "gateway_client.h" static DECLARE_DELAYED_WORK(purge_orig_wq, purge_orig);
@@ -241,6 +241,8 @@ void purge_orig(struct work_struct *work)while (hash_iterate (orig_hash, &hashit)) { orig_node = hashit.bucket->data;if (purge_orig_node (orig_node)) { +if (orig_node->gw_flags) +gw_node_delete (orig_node);hash_remove_bucket (orig_hash, &hashit);free_orig_node (orig_node); }
@@ -248,5 +250,7 @@ void purge_orig(struct work_struct *work)spin_unlock_irqrestore (&orig_hash_lock, flags); +gw_node_purge_deleted (); +gw_election ();start_purge_timer (); }
batman-adv-kernelland/packet.h +3 -1
@@ -28,7 +28,7 @@#define BAT_VIS 0x05/* this file is included by batctl which needs these defines */ -#define COMPAT_VERSION 8 +#define COMPAT_VERSION 9#define DIRECTLINK 0x40#define VIS_SERVER 0x20
@@ -53,6 +53,8 @@ struct batman_packet {uint8_t prev_sender[6 ];uint8_t ttl;uint8_t num_hna; +uint8_t gw_flags;/* flags related to gateway class */ +uint8_t align; } __attribute__((packed));#define BAT_PACKET_LEN sizeof(struct batman_packet)
batman-adv-kernelland/proc.c +144 -0
179 lines not on this page · raw message
batman-adv-kernelland/proc.h +2 -0
@@ -34,6 +34,8 @@#define PROC_FILE_VIS_SRV "vis_server"#define PROC_FILE_VIS_DATA "vis_data"#define PROC_FILE_AGGR "aggregate_ogm" +#define PROC_FILE_GW_MODE "gateway_mode" +#define PROC_FILE_GW_SRV_LIST "gateway_srv_list"void cleanup_procfs (void );int setup_procfs (void );
batman-adv-kernelland/routing.c +12 -1
@@ -33,6 +33,7 @@#include "vis.h" #include "aggregation.h" #include "compat.h" +#include "gateway_client.h" DECLARE_WAIT_QUEUE_HEAD (thread_wait);
@@ -306,10 +307,20 @@ static void update_orig(struct orig_node *orig_node, struct ethhdr *ethhdr, goto update_hna;update_routes (orig_node, neigh_node, hna_buff, tmp_hna_buff_len); -return ; + goto update_gw; update_hna:update_routes (orig_node, orig_node->router, hna_buff, tmp_hna_buff_len); + +update_gw: +if (orig_node->gw_flags != batman_packet->gw_flags) +gw_node_update (orig_node, batman_packet->gw_flags); + + orig_node->gw_flags = batman_packet->gw_flags; + +/* restart gateway selection if fast or late switching was enabled */ +if ((orig_node->gw_flags) && (atomic_read (&gw_clnt_class) >2 )) +gw_check_election (orig_node); } static char count_real_packets(struct ethhdr *ethhdr,
batman-adv-kernelland/send.c +3 -0
@@ -28,6 +28,7 @@#include "types.h" #include "vis.h" #include "aggregation.h" +#include "gateway_common.h" #include "compat.h"
@@ -279,6 +280,8 @@ void schedule_own_packet(struct batman_if *batman_if)else batman_packet->flags =0 ; + batman_packet->gw_flags = (uint8_t )atomic_read (&gw_srv_class); +/* could be read by receive_bat_packet() */ atomic_inc (&batman_if->seqno);
batman-adv-kernelland/types.h +10 -4
@@ -43,7 +43,6 @@ struct batman_if {unsigned char *packet_buff;int packet_len;struct rcu_head rcu; - };struct orig_node {/* structure for orig_list maintaining nodes of mesh */
@@ -55,10 +54,10 @@ struct orig_node { /* structure for orig_list maintaining nodes ofuint8_t tq_own;int tq_asym_penalty;unsigned long last_valid;/* when last packet from this node was received */ -/* uint8_t gwflags; * flags related to gateway functions: gateway class */ -uint8_t flags;/* for now only VIS_SERVER flag. */ +uint8_t gw_flags;/* flags related to gateway class */ +uint8_t flags;/* for now only VIS_SERVER flag. */ unsigned char *hna_buff; -int16_t hna_buff_len; +int16_t hna_buff_len;uint16_t last_real_seqno;/* last and best known squence number */ uint8_t last_ttl;/* ttl of last received packet */ TYPE_OF_WORD bcast_bits[NUM_WORDS ];
@@ -66,6 +65,13 @@ struct orig_node { /* structure for orig_list maintaining nodes ofstruct list_head neigh_list; }; +struct gw_node { +struct list_head list; +struct orig_node *orig_node; +unsigned long deleted; +struct rcu_head rcu; +}; +struct neigh_node {struct list_head list;uint8_t addr[ETH_ALEN ];
Signature · 1 line
1.6.5.7
PATCH 2/3 batctl: add support for gateway mode
--- batctl/main.c | 10 ++++++++++ batctl/man/batctl.8 | 6 ++++++ batctl/proc.c | 16 ++++++++++++++++ batctl/proc.h | 8 ++++---- 4 files changed, 36 insertions(+), 4 deletions(-)
batctl/main.c +10 -0
@@ -46,6 +46,8 @@ void print_usage(void) {printf (" \tinterval|it [orig_interval] \tdisplay or modify the originator interval in ms\n" );printf (" \tloglevel|ll [level] \tdisplay or modify the log level\n" );printf (" \tlog|l \tread the log produced by the kernel module\n" ); +printf (" \tgw_mode|gw [mode] \tdisplay or modify the gateway mode\n" ); +printf (" \tgw_srv_list|gwl \tdisplay the gateway server list\n" );printf (" \ttranslocal|tl \tdisplay the local translation table\n" );printf (" \ttransglobal|tg \tdisplay the global translation table\n" );printf (" \tvis_server|vs [enable|disable] \tdisplay or modify the status of the VIS server\n" );
@@ -130,6 +132,14 @@ int main(int argc, char **argv) ret =vis_data (argc -1 , argv +1 ); + }else if ((strcmp (argv[1 ],"gw_mode" ) ==0 ) || (strcmp (argv[1 ],"gw" ) ==0 )) { + + ret =handle_proc_setting (argc -1 , argv +1 ,PROC_GW_MODE , gw_mode_usage); + + }else if ((strcmp (argv[1 ],"gw_srv_list" ) ==0 ) || (strcmp (argv[1 ],"gwl" ) ==0 )) { + + ret =handle_table (argc -1 , argv +1 ,PROC_GW_SRV_LIST , gw_srv_list_usage); + }else if ((strcmp (argv[1 ],"aggregation" ) ==0 ) || (strcmp (argv[1 ],"ag" ) ==0 )) { ret =handle_proc_setting (argc -1 , argv +1 ,PROC_AGGR , aggregation_usage);
batctl/man/batctl.8 +6 -0
@@ -57,6 +57,12 @@ If no parameter is given the current log level settings are displayed otherwise .IP "\fBlog|l\fP " Once started batctl will continuously read the log produced by the kernel module (the amount of log message can be influenced by modifying the log level). Whenever there are new log messages sent by the kernel batctl will display it. Use the "\-b" option to let batctl exit after the existing log buffer has been displayed. If "\-n" was given batctl will not replace the mac addresses with bat\-host names in the output. .br +.IP "\fBgw_mode|gw [off|client|server]\fP" +If no parameter is given the current gateway mode is displayed otherwise the parameter is used to set the gateway mode. +.br +.IP "\fBgw_srv_list|gwl\fP" +Once started batctl will refresh the displayed gateway server list every second. Use the "\-b" option to let batctl display the list only once (useful for scripts). If "\-n" was given batctl will not replace the mac addresses with bat\-host names in the output. +.br .IP "\fBtranslocal|tl\fP" Once started batctl will refresh the displayed local translation table every second. Use the "\-b" option to let batctl display the table only once (useful for scripts). If "\-n" was given batctl will not replace the mac addresses with bat\-host names in the output. .br
batctl/proc.c +16 -0
@@ -95,6 +95,15 @@ void trans_global_usage(void)printf (" \t -n don't replace mac addresses with bat-host names\n" ); } +void gw_srv_list_usage (void ) +{ +printf ("Usage: batctl [options] gw_srv_list \n" ); +printf ("options:\n" ); +printf (" \t -b batch mode - read the gateway server list once and quit\n" ); +printf (" \t -h print this help\n" ); +printf (" \t -n don't replace mac addresses with bat-host names\n" ); +} +void orig_interval_usage (void ) {printf ("Usage: batctl [options] interval \n" );
@@ -116,6 +125,13 @@ void aggregation_usage(void)printf (" \t -h print this help\n" ); } +void gw_mode_usage (void ) +{ +printf ("Usage: batctl [options] gw_mode [mode]\n" ); +printf ("options:\n" ); +printf (" \t -h print this help\n" ); +} +int handle_table (int argc,char **argv,char *file_path,void table_usage (void )) {int optchar, read_opt =CLR_CONT_READ |USE_BAT_HOSTS ;
batctl/proc.h +4 -4
@@ -19,19 +19,17 @@* */ - -#define PROC_ROOT_PATH "/proc/net/batman-adv/"#define PROC_INTERFACES "interfaces"#define PROC_ORIGINATORS "originators"#define PROC_ORIG_INTERVAL "orig_interval" -#define PROC_GATEWAYS "gateways"#define PROC_TRANSTABLE_LOCAL "transtable_local"#define PROC_TRANSTABLE_GLOBAL "transtable_global"#define PROC_VIS_SERVER "vis_server"#define PROC_VIS_DATA "vis_data"#define PROC_AGGR "aggregate_ogm" - +#define PROC_GW_MODE "gateway_mode" +#define PROC_GW_SRV_LIST "gateway_srv_list"int interface (int argc,char **argv);
@@ -41,5 +39,7 @@ void trans_global_usage(void);void orig_interval_usage (void );void vis_server_usage (void );void aggregation_usage (void ); +void gw_mode_usage (void ); +void gw_srv_list_usage (void );int handle_table (int argc,char **argv,char *file_path,void table_usage (void ));int handle_proc_setting (int argc,char **argv,char *file_path,void setting_usage (void ));
Signature · 1 line
1.6.5.7
PATCH 3/3 batman-adv: send DHCP requests directly to the chosen gw
If the gateway client mode is active batman-adv will send the broadcasted DHCP requests via unicast to the currently selected best gateway. Therefore attached clients can profit from batman's knowledge about the network topology.
--- batman-adv-kernelland/gateway_client.c | 45 ++++++++++++++++++++++++++++++++ batman-adv-kernelland/gateway_client.h | 2 + batman-adv-kernelland/soft-interface.c | 17 ++++++++++-- 3 files changed, 61 insertions(+), 3 deletions(-)
batman-adv-kernelland/gateway_client.c +45 -0
@@ -20,6 +20,8 @@#include "main.h" #include "gateway_client.h" #include "gateway_common.h" +#include <linux/ip.h> +#include <linux/udp.h> LIST_HEAD (gw_list);DEFINE_SPINLOCK (curr_gw_lock);
@@ -27,6 +29,20 @@ DEFINE_SPINLOCK(gw_list_lock);atomic_t gw_clnt_class;static struct gw_node *curr_gateway; +void *gw_get_selected (void ) +{ +struct gw_node *curr_gateway_tmp =NULL ; + +spin_lock (&curr_gw_lock); + curr_gateway_tmp = curr_gateway; +spin_unlock (&curr_gw_lock); + +if (!curr_gateway_tmp) +return NULL ; + +return curr_gateway_tmp->orig_node; +} +void gw_deselect (void ) {spin_lock (&curr_gw_lock);
@@ -333,3 +349,32 @@ int gw_client_fill_buffer_text(unsigned char *buff, int buff_len)return bytes_written; } + +bool gw_is_target (struct sk_buff *skb) +{ +struct ethhdr *ethhdr; +struct iphdr *iphdr; +struct udphdr *udphdr; + +if (atomic_read (&gw_mode) !=GW_MODE_CLIENT ) +return false; + +if (!curr_gateway) +return false; + + ethhdr = (struct ethhdr *)skb->data; +if (ntohs (ethhdr->h_proto) !=ETH_P_IP ) +return false; + + iphdr = (struct iphdr *)(skb->data +ETH_HLEN ); + +if (iphdr->protocol !=IPPROTO_UDP ) +return false; + + udphdr = (struct udphdr *)(skb->data +ETH_HLEN + (iphdr->ihl *4 )); + +if (ntohs (udphdr->dest) !=67 ) +return false; + +return true; +}
batman-adv-kernelland/gateway_client.h +2 -0
@@ -21,9 +21,11 @@ extern atomic_t gw_clnt_class;void gw_deselect (void );void gw_election (void ); +void *gw_get_selected (void );void gw_check_election (struct orig_node *orig_node);void gw_node_update (struct orig_node *orig_node,uint8_t new_gwflags);void gw_node_delete (struct orig_node *orig_node);void gw_node_purge_deleted (void );void gw_node_list_free (void );int gw_client_fill_buffer_text (unsigned char *buff,int buff_len); +bool gw_is_target (struct sk_buff *skb);
batman-adv-kernelland/soft-interface.c +14 -3
@@ -26,6 +26,7 @@#include "translation-table.h" #include "types.h" #include "hash.h" +#include "gateway_client.h" #include <linux/ethtool.h> #include <linux/etherdevice.h> #include "compat.h"
@@ -181,6 +182,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)uint8_t dstaddr[6 ];int data_len = skb->len;unsigned long flags; +bool bcast_dst = false, do_bcast = true;if (atomic_read (&module_state) !=MODULE_ACTIVE ) goto dropped;
@@ -189,9 +191,14 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)/* TODO: check this for locks */ hna_local_add (ethhdr->h_source); -/* ethernet packet should be broadcasted */ -if (is_bcast (ethhdr->h_dest) ||is_mcast (ethhdr->h_dest)) { +if (is_bcast (ethhdr->h_dest) ||is_mcast (ethhdr->h_dest)) + bcast_dst = true; + +if ((bcast_dst) &&gw_is_target (skb)) + do_bcast = false; +/* ethernet packet should be broadcasted */ +if (bcast_dst && do_bcast) {if (my_skb_push (skb,sizeof (struct bcast_packet )) <0 ) goto dropped;
@@ -219,8 +226,12 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)/* unicast packet */ }else {spin_lock_irqsave (&orig_hash_lock, flags); +/* get routing information */ - orig_node = ((struct orig_node *)hash_find (orig_hash, +if (bcast_dst) + orig_node = (struct orig_node *)gw_get_selected (); +else + orig_node = ((struct orig_node *)hash_find (orig_hash, ethhdr->h_dest));/* check for hna host */
Signature · 1 line
1.6.5.7
Re: [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: send DHCP requests directly to the chosen gw
Quoted 25 lines
batman-adv-kernelland/gateway_client.c +25
-0+bool gw_is_target (struct sk_buff *skb) +{ +struct ethhdr *ethhdr; +struct iphdr *iphdr; +struct udphdr *udphdr; + +if (atomic_read (&gw_mode) !=GW_MODE_CLIENT ) +return false; + +if (!curr_gateway) +return false; + + ethhdr = (struct ethhdr *)skb->data; +if (ntohs (ethhdr->h_proto) !=ETH_P_IP ) +return false; + + iphdr = (struct iphdr *)(skb->data +ETH_HLEN ); + +if (iphdr->protocol !=IPPROTO_UDP ) +return false; + + udphdr = (struct udphdr *)(skb->data +ETH_HLEN + (iphdr->ihl *4 )); + +if (ntohs (udphdr->dest) !=67 ) +return false;
batman-adv-kernelland/gateway_client.c int gw_client_fill_buffer_text(unsigned char *buff, int buff_len)
Quoted 10 lines
batman-adv-kernelland/gateway_client.c +8
-2+ +return true; +} -/* ethernet packet should be broadcasted */ -if (is_bcast (ethhdr->h_dest) ||is_mcast (ethhdr->h_dest)) { +if (is_bcast (ethhdr->h_dest) ||is_mcast (ethhdr->h_dest)) + bcast_dst = true; + +if ((bcast_dst) &&gw_is_target (skb)) + do_bcast = false;
Say the DHCP server is running in client mode. It has also been requested to broadcast its replies, not unicast the replies.
http://blogs.technet.com/teamdhcp/archive/2009/02/12/dhcp-broadcast-flag-handling-in-windows-7.aspx
If i'm reading this code correctly, it will end up sending the DHCP reply messages by unicast to the best gateway, not the DHCP client?
Andrew
Re: [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: send DHCP requests directly to the chosen gw
Quoted 8 lines · On Tuesday 05 January 2010 14:43:49 you wrote:
Say the DHCP server is running in client mode. It has also been requested to broadcast its replies, not unicast the replies.
http://blogs.technet.com/teamdhcp/archive/2009/02/12/dhcp-broadcast-flag-ha
ndling-in-windows-7.aspxIf i'm reading this code correctly, it will end up sending the DHCP reply messages by unicast to the best gateway, not the DHCP client?
I don't really get your question.
The batman-adv gwclient will encapsulate the DHCP discover / request packets in ethernet unicast headers instead of broadcast headers to make sure only the best gateway receives these broadcasts.
The server's replies won't be affected at all.
Regards,
Marek
Re: [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: send DHCP requests directly to the chosen gw
Quoted 7 lines · On Tuesday 05 January 2010 14:43:49 you wrote:
Quoted 6 lines
Say the DHCP server is running in client mode. It has also been requested to broadcast its replies, not unicast the replies.
http://blogs.technet.com/teamdhcp/archive/2009/02/12/dhcp-broadcast-flag-ha
ndling-in-windows-7.aspx
Quoted 8 lines
Quoted 2 lines
If i'm reading this code correctly, it will end up sending the DHCP reply messages by unicast to the best gateway, not the DHCP client?
I don't really get your question.
The batman-adv gwclient will encapsulate the DHCP discover / request packets in ethernet unicast headers instead of broadcast headers to make sure only the best gateway receives these broadcasts.
The server's replies won't be affected at all.
Ah, just read the RFC. I though the client was free to choose its port, so it could choose port 67. If that was true, gw_is_target() would return true for the reply and the reply would then be sent to the gateway.
However, the RFC says the client must use port 68, so this can never happen. So there is no problem here...
Andrew
hi,
why can I not unsubscribe from this list?
Quoted 1 line · predrag balorda
predrag balorda <[email protected]>
You can. Just go to https://lists.open-mesh.net/mm/listinfo/b.a.t.m.a.n, enter your mail and click "Unsubscribe or edit options" -> "unsubscribe" and then reply to the mail you have received.
Best regards,
Sven
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 2 lines · predrag balorda
I've done it 3 times in the last few days and nothing ever happened. Just as I wrote to the list a removal confirmation arrived.
Yes, I did it for you as explained.
Best regards,
Sven
Hi
Quoted 7 lines · Marek Lindner
* The third patch checks whether locally received packets are DHCP queries and
forwards them via uncicast to the best gateway instead of broadcasting them.Would it be possible to decide via a more general mechanism, maybe via a
BPF filter, which packets get sent to the gateway? For instance, it would be nice to be able to say that all ARP requests for *.*.*.1 also got sent to the gateway direct :-) This would also make adding IPv6 support trivial, it'd just be another (or a more complex) BPF filter.
donald
Quoted 5 lines
Would it be possible to decide via a more general mechanism, maybe via a BPF filter, which packets get sent to the gateway? For instance, it would be nice to be able to say that all ARP requests for *.*.*.1 also got sent to the gateway direct :-) This would also make adding IPv6 support trivial, it'd just be another (or a more complex) BPF filter.
BPF for outgoing packets? Different. I've only ever seen it used for filtering incoming packets. ARP requests for *.*.*.1? I don't get that. There should only be one host in the subnet which matches *.*.*.1/24, so its going to reply anyway. What are you trying to achieve here?
Also, how would you handle the gateway sending back an ICMP redirect because it is the wrong gateway for a given destination, or not a gateway at all? In the network i use most, *.*.*.5/24 happens to be the gateway, not *.*.*.1.
Andrew
Quoted 7 lines · Andrew Lunn
BPF for outgoing packets? Different. I've only ever seen it used for filtering incoming packets. ARP requests for *.*.*.1? I don't get that. There should only be one host in the subnet which matches *.*.*.1/24, so its going to reply anyway. What are you trying to achieve here?
BPF because it's already in the kernel and has a rule language. Rules to match "all DHCP packets, and IPv6 router solicitations" are easy to write, and people who want to do something different/wierd don't need to rebuild their kernels.
If it makes any more sense, substitute *.*.*.1 for "something matching the IPs I use for gateways". Aim: make it harder for people to configure their PCs to respond to those ARPs and break the network. Although for a mobile node whose DHCP lease hasn't yet expired I can see that causing problems. But if it's just a BPF filter then you can experiment with rules like these fairly easily.
donald
Hi,
despite the general, internal filtering rules it would be great to be able to fetch the best gateway (the gateway with the best BTM-TQ value) via /proc. So people would have the chance to use the basic gatewaying feature with just a switch in batman-adv, while people that want to do more complex filtering could fetch it from /proc and use ebtables on top for example. Maybe even a sorted list of all gateways in /proc would be nice to be able to set up some more advanced (fall-back) scenarios with other measuring methods/tools. And on the other hand we'd have the possibility of batman-adv not interfering too much with the other layers, instead tools explicitly designed for layer 2, 3, ... have an interface to fetch the gateway information then which only batman-adv knew before.
I think I've been talking about this partly with Marek a couple of weeks ago before.
Cheers, Linus
Quoted 22 lines · Donald Gordon
Hi
Quoted 7 lines · Marek Lindner
* The third patch checks whether locally received packets are DHCP queries and
forwards them via uncicast to the best gateway instead of broadcasting them.Would it be possible to decide via a more general mechanism, maybe via a
BPF filter, which packets get sent to the gateway? For instance, it would be nice to be able to say that all ARP requests for *.*.*.1 also got sent to the gateway direct :-) This would also make adding IPv6 support trivial, it'd just be another (or a more complex) BPF filter.
donald
_______________________________________________
B.A.T.M.A.N mailing list
[email protected]
https://lists.open-mesh.net/mm/listinfo/b.a.t.m.a.n
Hi
Quoted 8 lines · Linus Lüssing
Maybe even a
sorted list of all gateways in /proc would be nice to be able to set up some more advanced (fall-back) scenarios with other measuring methods/tools. And on the other hand we'd have the possibility of batman-adv not interfering too much with the other layers, instead tools explicitly designed for layer 2, 3, ... have an interface to fetch the gateway information then which only batman-adv knew before.
That would be even better than what I was suggesting. It would, among other things, make it easy (with the addition of some sort of directory in userspace, or redefining the gateway flags) to find the closest node(s) with some particular service. I'm thinking of things like "all squids that are nearby".
donald
Quoted 3 lines
* The third patch checks whether locally received packets are DHCP queries and forwards them via uncicast to the best gateway instead of broadcasting them.
Can this be made a bit more robust? An easy DoS would be to offer to be a gateway, but not run DHCP. All my near neighbours then fail to get an IP address and i have quiet network with more bandwidth for myself.
Could we inspect the DHCP packet a bit more deeply, look for DHCP discovery packets, unicast 3 in 4 to the best gateway, broadcast 1 in 4 as a fallback.
Andrew
Quoted 4 lines · On Tuesday 05 January 2010 14:31:46 Andrew Lunn wrote:
Can this be made a bit more robust? An easy DoS would be to offer to be a gateway, but not run DHCP. All my near neighbours then fail to get an IP address and i have quiet network with more bandwidth for myself.
Good point. Before I had another scheme in mind: DHCP requests are broadcasted but the batman-adv client would filter the responses preferring the selected gateway if its reply is available. Of course, that is more complex to implement.
Quoted 3 lines
Could we inspect the DHCP packet a bit more deeply, look for DHCP discovery packets, unicast 3 in 4 to the best gateway, broadcast 1 in 4 as a fallback.
I'm not sure this approach is feasible. As soon as we broadcast a single packet we might end up with a badly chosen gateway.
The batman daemon is able to blacklist broken gateways and switches to another one. We may want to do the same.
Regards,
Marek