Commit 6c413b1c authored by Antonio Quartulli's avatar Antonio Quartulli Committed by Antonio Quartulli

batman-adv: send every DHCP packet as bat-unicast

In different situations it is possible that the DHCP server
or client uses broadcast Ethernet frames to send messages
to each other. The GW component in batman-adv takes care of
using bat-unicast packets to bring broadcast DHCP
Discover/Requests to the "best" server.

On the way back the DHCP server usually sends unicasts,
but upon client request it may decide to use broadcasts as
well.

This patch improves the GW component so that it now snoops
and sends as unicast all the DHCP packets, no matter if they
were generated by a DHCP server or client.
Signed-off-by: default avatarAntonio Quartulli <antonio@open-mesh.com>
Signed-off-by: default avatarMarek Lindner <mareklindner@neomailbox.ch>
parent 36484f84
...@@ -1037,9 +1037,9 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv, ...@@ -1037,9 +1037,9 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
if (hdr_size == sizeof(struct batadv_unicast_4addr_packet)) if (hdr_size == sizeof(struct batadv_unicast_4addr_packet))
err = batadv_send_skb_via_tt_4addr(bat_priv, skb_new, err = batadv_send_skb_via_tt_4addr(bat_priv, skb_new,
BATADV_P_DAT_CACHE_REPLY, BATADV_P_DAT_CACHE_REPLY,
vid); NULL, vid);
else else
err = batadv_send_skb_via_tt(bat_priv, skb_new, vid); err = batadv_send_skb_via_tt(bat_priv, skb_new, NULL, vid);
if (err != NET_XMIT_DROP) { if (err != NET_XMIT_DROP) {
batadv_inc_counter(bat_priv, BATADV_CNT_DAT_CACHED_REPLY_TX); batadv_inc_counter(bat_priv, BATADV_CNT_DAT_CACHED_REPLY_TX);
......
...@@ -28,11 +28,17 @@ ...@@ -28,11 +28,17 @@
#include <linux/udp.h> #include <linux/udp.h>
#include <linux/if_vlan.h> #include <linux/if_vlan.h>
/* This is the offset of the options field in a dhcp packet starting at /* These are the offsets of the "hw type" and "hw address length" in the dhcp
* the beginning of the dhcp header * packet starting at the beginning of the dhcp header
*/ */
#define BATADV_DHCP_OPTIONS_OFFSET 240 #define BATADV_DHCP_HTYPE_OFFSET 1
#define BATADV_DHCP_REQUEST 3 #define BATADV_DHCP_HLEN_OFFSET 2
/* Value of htype representing Ethernet */
#define BATADV_DHCP_HTYPE_ETHERNET 0x01
/* This is the offset of the "chaddr" field in the dhcp packet starting at the
* beginning of the dhcp header
*/
#define BATADV_DHCP_CHADDR_OFFSET 28
static void batadv_gw_node_free_ref(struct batadv_gw_node *gw_node) static void batadv_gw_node_free_ref(struct batadv_gw_node *gw_node)
{ {
...@@ -596,80 +602,39 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset) ...@@ -596,80 +602,39 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
return 0; return 0;
} }
/* this call might reallocate skb data */ /**
static bool batadv_is_type_dhcprequest(struct sk_buff *skb, int header_len) * batadv_gw_dhcp_recipient_get - check if a packet is a DHCP message
{ * @skb: the packet to check
int ret = false; * @header_len: a pointer to the batman-adv header size
unsigned char *p; * @chaddr: buffer where the client address will be stored. Valid
int pkt_len; * only if the function returns BATADV_DHCP_TO_CLIENT
*
if (skb_linearize(skb) < 0) * Returns:
goto out; * - BATADV_DHCP_NO if the packet is not a dhcp message or if there was an error
* while parsing it
pkt_len = skb_headlen(skb); * - BATADV_DHCP_TO_SERVER if this is a message going to the DHCP server
* - BATADV_DHCP_TO_CLIENT if this is a message going to a DHCP client
if (pkt_len < header_len + BATADV_DHCP_OPTIONS_OFFSET + 1) *
goto out; * This function may re-allocate the data buffer of the skb passed as argument.
*/
p = skb->data + header_len + BATADV_DHCP_OPTIONS_OFFSET; enum batadv_dhcp_recipient
pkt_len -= header_len + BATADV_DHCP_OPTIONS_OFFSET + 1; batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
uint8_t *chaddr)
/* Access the dhcp option lists. Each entry is made up by:
* - octet 1: option type
* - octet 2: option data len (only if type != 255 and 0)
* - octet 3: option data
*/
while (*p != 255 && !ret) {
/* p now points to the first octet: option type */
if (*p == 53) {
/* type 53 is the message type option.
* Jump the len octet and go to the data octet
*/
if (pkt_len < 2)
goto out;
p += 2;
/* check if the message type is what we need */
if (*p == BATADV_DHCP_REQUEST)
ret = true;
break;
} else if (*p == 0) {
/* option type 0 (padding), just go forward */
if (pkt_len < 1)
goto out;
pkt_len--;
p++;
} else {
/* This is any other option. So we get the length... */
if (pkt_len < 1)
goto out;
pkt_len--;
p++;
/* ...and then we jump over the data */
if (pkt_len < 1 + (*p))
goto out;
pkt_len -= 1 + (*p);
p += 1 + (*p);
}
}
out:
return ret;
}
/* this call might reallocate skb data */
bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
{ {
enum batadv_dhcp_recipient ret = BATADV_DHCP_NO;
struct ethhdr *ethhdr; struct ethhdr *ethhdr;
struct iphdr *iphdr; struct iphdr *iphdr;
struct ipv6hdr *ipv6hdr; struct ipv6hdr *ipv6hdr;
struct udphdr *udphdr; struct udphdr *udphdr;
struct vlan_ethhdr *vhdr; struct vlan_ethhdr *vhdr;
int chaddr_offset;
__be16 proto; __be16 proto;
uint8_t *p;
/* check for ethernet header */ /* check for ethernet header */
if (!pskb_may_pull(skb, *header_len + ETH_HLEN)) if (!pskb_may_pull(skb, *header_len + ETH_HLEN))
return false; return BATADV_DHCP_NO;
ethhdr = (struct ethhdr *)skb->data; ethhdr = (struct ethhdr *)skb->data;
proto = ethhdr->h_proto; proto = ethhdr->h_proto;
*header_len += ETH_HLEN; *header_len += ETH_HLEN;
...@@ -677,7 +642,7 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len) ...@@ -677,7 +642,7 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
/* check for initial vlan header */ /* check for initial vlan header */
if (proto == htons(ETH_P_8021Q)) { if (proto == htons(ETH_P_8021Q)) {
if (!pskb_may_pull(skb, *header_len + VLAN_HLEN)) if (!pskb_may_pull(skb, *header_len + VLAN_HLEN))
return false; return BATADV_DHCP_NO;
vhdr = (struct vlan_ethhdr *)skb->data; vhdr = (struct vlan_ethhdr *)skb->data;
proto = vhdr->h_vlan_encapsulated_proto; proto = vhdr->h_vlan_encapsulated_proto;
...@@ -688,32 +653,34 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len) ...@@ -688,32 +653,34 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
switch (proto) { switch (proto) {
case htons(ETH_P_IP): case htons(ETH_P_IP):
if (!pskb_may_pull(skb, *header_len + sizeof(*iphdr))) if (!pskb_may_pull(skb, *header_len + sizeof(*iphdr)))
return false; return BATADV_DHCP_NO;
iphdr = (struct iphdr *)(skb->data + *header_len); iphdr = (struct iphdr *)(skb->data + *header_len);
*header_len += iphdr->ihl * 4; *header_len += iphdr->ihl * 4;
/* check for udp header */ /* check for udp header */
if (iphdr->protocol != IPPROTO_UDP) if (iphdr->protocol != IPPROTO_UDP)
return false; return BATADV_DHCP_NO;
break; break;
case htons(ETH_P_IPV6): case htons(ETH_P_IPV6):
if (!pskb_may_pull(skb, *header_len + sizeof(*ipv6hdr))) if (!pskb_may_pull(skb, *header_len + sizeof(*ipv6hdr)))
return false; return BATADV_DHCP_NO;
ipv6hdr = (struct ipv6hdr *)(skb->data + *header_len); ipv6hdr = (struct ipv6hdr *)(skb->data + *header_len);
*header_len += sizeof(*ipv6hdr); *header_len += sizeof(*ipv6hdr);
/* check for udp header */ /* check for udp header */
if (ipv6hdr->nexthdr != IPPROTO_UDP) if (ipv6hdr->nexthdr != IPPROTO_UDP)
return false; return BATADV_DHCP_NO;
break; break;
default: default:
return false; return BATADV_DHCP_NO;
} }
if (!pskb_may_pull(skb, *header_len + sizeof(*udphdr))) if (!pskb_may_pull(skb, *header_len + sizeof(*udphdr)))
return false; return BATADV_DHCP_NO;
/* skb->data might have been reallocated by pskb_may_pull() */ /* skb->data might have been reallocated by pskb_may_pull() */
ethhdr = (struct ethhdr *)skb->data; ethhdr = (struct ethhdr *)skb->data;
...@@ -724,17 +691,40 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len) ...@@ -724,17 +691,40 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
*header_len += sizeof(*udphdr); *header_len += sizeof(*udphdr);
/* check for bootp port */ /* check for bootp port */
if ((proto == htons(ETH_P_IP)) && switch (proto) {
(udphdr->dest != htons(67))) case htons(ETH_P_IP):
return false; if (udphdr->dest == htons(67))
ret = BATADV_DHCP_TO_SERVER;
else if (udphdr->source == htons(67))
ret = BATADV_DHCP_TO_CLIENT;
break;
case htons(ETH_P_IPV6):
if (udphdr->dest == htons(547))
ret = BATADV_DHCP_TO_SERVER;
else if (udphdr->source == htons(547))
ret = BATADV_DHCP_TO_CLIENT;
break;
}
if ((proto == htons(ETH_P_IPV6)) && chaddr_offset = *header_len + BATADV_DHCP_CHADDR_OFFSET;
(udphdr->dest != htons(547))) /* store the client address if the message is going to a client */
return false; if (ret == BATADV_DHCP_TO_CLIENT &&
pskb_may_pull(skb, chaddr_offset + ETH_ALEN)) {
/* check if the DHCP packet carries an Ethernet DHCP */
p = skb->data + *header_len + BATADV_DHCP_HTYPE_OFFSET;
if (*p != BATADV_DHCP_HTYPE_ETHERNET)
return BATADV_DHCP_NO;
/* check if the DHCP packet carries a valid Ethernet address */
p = skb->data + *header_len + BATADV_DHCP_HLEN_OFFSET;
if (*p != ETH_ALEN)
return BATADV_DHCP_NO;
memcpy(chaddr, skb->data + chaddr_offset, ETH_ALEN);
}
return true; return ret;
} }
/** /**
* batadv_gw_out_of_range - check if the dhcp request destination is the best gw * batadv_gw_out_of_range - check if the dhcp request destination is the best gw
* @bat_priv: the bat priv with all the soft interface information * @bat_priv: the bat priv with all the soft interface information
...@@ -748,6 +738,7 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len) ...@@ -748,6 +738,7 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
* false otherwise. * false otherwise.
* *
* This call might reallocate skb data. * This call might reallocate skb data.
* Must be invoked only when the DHCP packet is going TO a DHCP SERVER.
*/ */
bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
struct sk_buff *skb) struct sk_buff *skb)
...@@ -755,19 +746,13 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, ...@@ -755,19 +746,13 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
struct batadv_neigh_node *neigh_curr = NULL, *neigh_old = NULL; struct batadv_neigh_node *neigh_curr = NULL, *neigh_old = NULL;
struct batadv_orig_node *orig_dst_node = NULL; struct batadv_orig_node *orig_dst_node = NULL;
struct batadv_gw_node *gw_node = NULL, *curr_gw = NULL; struct batadv_gw_node *gw_node = NULL, *curr_gw = NULL;
struct ethhdr *ethhdr; struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
bool ret, out_of_range = false; bool out_of_range = false;
unsigned int header_len = 0;
uint8_t curr_tq_avg; uint8_t curr_tq_avg;
unsigned short vid; unsigned short vid;
vid = batadv_get_vid(skb, 0); vid = batadv_get_vid(skb, 0);
ret = batadv_gw_is_dhcp_target(skb, &header_len);
if (!ret)
goto out;
ethhdr = (struct ethhdr *)skb->data;
orig_dst_node = batadv_transtable_search(bat_priv, ethhdr->h_source, orig_dst_node = batadv_transtable_search(bat_priv, ethhdr->h_source,
ethhdr->h_dest, vid); ethhdr->h_dest, vid);
if (!orig_dst_node) if (!orig_dst_node)
...@@ -777,10 +762,6 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, ...@@ -777,10 +762,6 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
if (!gw_node->bandwidth_down == 0) if (!gw_node->bandwidth_down == 0)
goto out; goto out;
ret = batadv_is_type_dhcprequest(skb, header_len);
if (!ret)
goto out;
switch (atomic_read(&bat_priv->gw_mode)) { switch (atomic_read(&bat_priv->gw_mode)) {
case BATADV_GW_MODE_SERVER: case BATADV_GW_MODE_SERVER:
/* If we are a GW then we are our best GW. We can artificially /* If we are a GW then we are our best GW. We can artificially
......
...@@ -32,7 +32,9 @@ void batadv_gw_node_delete(struct batadv_priv *bat_priv, ...@@ -32,7 +32,9 @@ void batadv_gw_node_delete(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node); struct batadv_orig_node *orig_node);
void batadv_gw_node_purge(struct batadv_priv *bat_priv); void batadv_gw_node_purge(struct batadv_priv *bat_priv);
int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset); int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset);
bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len);
bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, struct sk_buff *skb); bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, struct sk_buff *skb);
enum batadv_dhcp_recipient
batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
uint8_t *chaddr);
#endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */ #endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */
...@@ -319,13 +319,23 @@ static int batadv_send_skb_unicast(struct batadv_priv *bat_priv, ...@@ -319,13 +319,23 @@ static int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
*/ */
int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv, int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
struct sk_buff *skb, int packet_type, struct sk_buff *skb, int packet_type,
int packet_subtype, unsigned short vid) int packet_subtype, uint8_t *dst_hint,
unsigned short vid)
{ {
struct ethhdr *ethhdr = (struct ethhdr *)skb->data; struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
struct batadv_orig_node *orig_node; struct batadv_orig_node *orig_node;
uint8_t *src, *dst;
src = ethhdr->h_source;
dst = ethhdr->h_dest;
/* if we got an hint! let's send the packet to this client (if any) */
if (dst_hint) {
src = NULL;
dst = dst_hint;
}
orig_node = batadv_transtable_search(bat_priv, src, dst, vid);
orig_node = batadv_transtable_search(bat_priv, ethhdr->h_source,
ethhdr->h_dest, vid);
return batadv_send_skb_unicast(bat_priv, skb, packet_type, return batadv_send_skb_unicast(bat_priv, skb, packet_type,
packet_subtype, orig_node, vid); packet_subtype, orig_node, vid);
} }
......
...@@ -38,7 +38,8 @@ bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv, ...@@ -38,7 +38,8 @@ bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv,
int packet_subtype); int packet_subtype);
int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv, int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
struct sk_buff *skb, int packet_type, struct sk_buff *skb, int packet_type,
int packet_subtype, unsigned short vid); int packet_subtype, uint8_t *dst_hint,
unsigned short vid);
int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb, int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
unsigned short vid); unsigned short vid);
...@@ -55,11 +56,11 @@ int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb, ...@@ -55,11 +56,11 @@ int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
* Returns NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise. * Returns NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
*/ */
static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv, static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv,
struct sk_buff *skb, struct sk_buff *skb, uint8_t *dst_hint,
unsigned short vid) unsigned short vid)
{ {
return batadv_send_skb_via_tt_generic(bat_priv, skb, BATADV_UNICAST, 0, return batadv_send_skb_via_tt_generic(bat_priv, skb, BATADV_UNICAST, 0,
vid); dst_hint, vid);
} }
/** /**
...@@ -79,11 +80,12 @@ static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv, ...@@ -79,11 +80,12 @@ static inline int batadv_send_skb_via_tt(struct batadv_priv *bat_priv,
static inline int batadv_send_skb_via_tt_4addr(struct batadv_priv *bat_priv, static inline int batadv_send_skb_via_tt_4addr(struct batadv_priv *bat_priv,
struct sk_buff *skb, struct sk_buff *skb,
int packet_subtype, int packet_subtype,
uint8_t *dst_hint,
unsigned short vid) unsigned short vid)
{ {
return batadv_send_skb_via_tt_generic(bat_priv, skb, return batadv_send_skb_via_tt_generic(bat_priv, skb,
BATADV_UNICAST_4ADDR, BATADV_UNICAST_4ADDR,
packet_subtype, vid); packet_subtype, dst_hint, vid);
} }
#endif /* _NET_BATMAN_ADV_SEND_H_ */ #endif /* _NET_BATMAN_ADV_SEND_H_ */
...@@ -160,6 +160,8 @@ static int batadv_interface_tx(struct sk_buff *skb, ...@@ -160,6 +160,8 @@ static int batadv_interface_tx(struct sk_buff *skb,
0x00, 0x00}; 0x00, 0x00};
static const uint8_t ectp_addr[ETH_ALEN] = {0xCF, 0x00, 0x00, 0x00, static const uint8_t ectp_addr[ETH_ALEN] = {0xCF, 0x00, 0x00, 0x00,
0x00, 0x00}; 0x00, 0x00};
enum batadv_dhcp_recipient dhcp_rcp = BATADV_DHCP_NO;
uint8_t *dst_hint = NULL, chaddr[ETH_ALEN];
struct vlan_ethhdr *vhdr; struct vlan_ethhdr *vhdr;
unsigned int header_len = 0; unsigned int header_len = 0;
int data_len = skb->len, ret; int data_len = skb->len, ret;
...@@ -167,6 +169,7 @@ static int batadv_interface_tx(struct sk_buff *skb, ...@@ -167,6 +169,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
bool do_bcast = false, client_added; bool do_bcast = false, client_added;
unsigned short vid; unsigned short vid;
uint32_t seqno; uint32_t seqno;
int gw_mode;
if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
goto dropped; goto dropped;
...@@ -213,36 +216,39 @@ static int batadv_interface_tx(struct sk_buff *skb, ...@@ -213,36 +216,39 @@ static int batadv_interface_tx(struct sk_buff *skb,
if (batadv_compare_eth(ethhdr->h_dest, ectp_addr)) if (batadv_compare_eth(ethhdr->h_dest, ectp_addr))
goto dropped; goto dropped;
gw_mode = atomic_read(&bat_priv->gw_mode);
if (is_multicast_ether_addr(ethhdr->h_dest)) { if (is_multicast_ether_addr(ethhdr->h_dest)) {
do_bcast = true; /* if gw mode is off, broadcast every packet */
if (gw_mode == BATADV_GW_MODE_OFF) {
switch (atomic_read(&bat_priv->gw_mode)) { do_bcast = true;
case BATADV_GW_MODE_SERVER: goto send;
/* gateway servers should not send dhcp
* requests into the mesh
*/
ret = batadv_gw_is_dhcp_target(skb, &header_len);
if (ret)
goto dropped;
break;
case BATADV_GW_MODE_CLIENT:
/* gateway clients should send dhcp requests
* via unicast to their gateway
*/
ret = batadv_gw_is_dhcp_target(skb, &header_len);
if (ret)
do_bcast = false;
break;
case BATADV_GW_MODE_OFF:
default:
break;
} }
/* reminder: ethhdr might have become unusable from here on dhcp_rcp = batadv_gw_dhcp_recipient_get(skb, &header_len,
* (batadv_gw_is_dhcp_target() might have reallocated skb data) chaddr);
/* skb->data may have been modified by
* batadv_gw_dhcp_recipient_get()
*/ */
ethhdr = (struct ethhdr *)skb->data;
/* if gw_mode is on, broadcast any non-DHCP message.
* All the DHCP packets are going to be sent as unicast
*/
if (dhcp_rcp == BATADV_DHCP_NO) {
do_bcast = true;
goto send;
}
if (dhcp_rcp == BATADV_DHCP_TO_CLIENT)
dst_hint = chaddr;
else if ((gw_mode == BATADV_GW_MODE_SERVER) &&
(dhcp_rcp == BATADV_DHCP_TO_SERVER))
/* gateways should not forward any DHCP message if
* directed to a DHCP server
*/
goto dropped;
} }
send:
batadv_skb_set_priority(skb, 0); batadv_skb_set_priority(skb, 0);
/* ethernet packet should be broadcasted */ /* ethernet packet should be broadcasted */
...@@ -288,22 +294,22 @@ static int batadv_interface_tx(struct sk_buff *skb, ...@@ -288,22 +294,22 @@ static int batadv_interface_tx(struct sk_buff *skb,
/* unicast packet */ /* unicast packet */
} else { } else {
if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_OFF) { /* DHCP packets going to a server will use the GW feature */
if (dhcp_rcp == BATADV_DHCP_TO_SERVER) {
ret = batadv_gw_out_of_range(bat_priv, skb); ret = batadv_gw_out_of_range(bat_priv, skb);
if (ret) if (ret)
goto dropped; goto dropped;
}
if (batadv_dat_snoop_outgoing_arp_request(bat_priv, skb))
goto dropped;
batadv_dat_snoop_outgoing_arp_reply(bat_priv, skb);
if (is_multicast_ether_addr(ethhdr->h_dest))
ret = batadv_send_skb_via_gw(bat_priv, skb, vid); ret = batadv_send_skb_via_gw(bat_priv, skb, vid);
else } else {
ret = batadv_send_skb_via_tt(bat_priv, skb, vid); if (batadv_dat_snoop_outgoing_arp_request(bat_priv,
skb))
goto dropped;
batadv_dat_snoop_outgoing_arp_reply(bat_priv, skb);
ret = batadv_send_skb_via_tt(bat_priv, skb, dst_hint,
vid);
}
if (ret == NET_XMIT_DROP) if (ret == NET_XMIT_DROP)
goto dropped_freed; goto dropped_freed;
} }
......
...@@ -33,6 +33,18 @@ ...@@ -33,6 +33,18 @@
#endif /* CONFIG_BATMAN_ADV_DAT */ #endif /* CONFIG_BATMAN_ADV_DAT */
/**
* enum batadv_dhcp_recipient - dhcp destination
* @BATADV_DHCP_NO: packet is not a dhcp message
* @BATADV_DHCP_TO_SERVER: dhcp message is directed to a server
* @BATADV_DHCP_TO_CLIENT: dhcp message is directed to a client
*/
enum batadv_dhcp_recipient {
BATADV_DHCP_NO = 0,
BATADV_DHCP_TO_SERVER,
BATADV_DHCP_TO_CLIENT,
};
/** /**
* BATADV_TT_REMOTE_MASK - bitmask selecting the flags that are sent over the * BATADV_TT_REMOTE_MASK - bitmask selecting the flags that are sent over the
* wire only * wire only
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment