Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save fpletz/b623783f7732c237dd9c to your computer and use it in GitHub Desktop.

Select an option

Save fpletz/b623783f7732c237dd9c to your computer and use it in GitHub Desktop.
gluon-build/patches/packages/routing/0004-Add-Filter-ICMPv6-router-advertisements-from-gateways.patch.patch
From: Your Name <[email protected]>
Date: Fri, 12 Jun 2015 21:40:11 +0000
Subject: Add Filter-ICMPv6-router-advertisements-from-gateways.patch
diff --git a/batman-adv/patches/0002-Filter-ICMPv6-router-advertisements-from-gateways.patch b/batman-adv/patches/0002-Filter-ICMPv6-router-advertisements-from-gateways.patch
new file mode 100644
index 0000000..ed4031f
--- /dev/null
+++ b/batman-adv/patches/0002-Filter-ICMPv6-router-advertisements-from-gateways.patch
@@ -0,0 +1,71 @@
+From c24c53258708e12b57656fb8f07c5ae4a02dcd07 Mon Sep 17 00:00:00 2001
+From: Franz Pletz <[email protected]>
+Date: Fri, 12 Jun 2015 23:35:01 +0200
+Subject: [PATCH] Filter ICMPv6 router advertisements from gateways
+
+---
+ gateway_client.c | 14 +++++++++++++-
+ gateway_client.h | 2 +-
+ soft-interface.c | 2 +-
+ 3 files changed, 15 insertions(+), 3 deletions(-)
+
+diff --git a/gateway_client.c b/gateway_client.c
+index e0bcf9e..2d6ae89 100644
+--- a/gateway_client.c
++++ b/gateway_client.c
+@@ -669,7 +669,7 @@ out:
+ */
+ enum batadv_dhcp_recipient
+ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
+- uint8_t *chaddr)
++ uint8_t *chaddr, uint8_t *gwaddr)
+ {
+ enum batadv_dhcp_recipient ret = BATADV_DHCP_NO;
+ struct ethhdr *ethhdr;
+@@ -724,6 +724,18 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
+ if (ipv6hdr->nexthdr != IPPROTO_UDP)
+ return BATADV_DHCP_NO;
+
++ /* ICMPv6 Router Adverstisement */
++ if (ipv6hdr->nexthdr == IPPROTO_ICMPV6) {
++ struct icmp6hdr *icmp6hdr = (struct icmp6hdr *)(skb->data + *header_len);
++ *header_len += sizeof(*icmp6hdr);
++
++ pr_info("icmpv6 packet from %x", *(ethhdr->h_source));
++
++ if (icmp6hdr->icmp6_type == NDISC_ROUTER_ADVERTISEMENT &&
++ memcmp(ethhdr->h_source, gwaddr, ETH_ALEN) == 0)
++ icmp6hdr->icmp6_rt_lifetime = 0;
++ }
++
+ break;
+ default:
+ return BATADV_DHCP_NO;
+diff --git a/gateway_client.h b/gateway_client.h
+index 7ee53bb..6deec8f 100644
+--- a/gateway_client.h
++++ b/gateway_client.h
+@@ -35,6 +35,6 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset);
+ 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);
++ uint8_t *chaddr, uint8_t *gwaddr);
+
+ #endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */
+diff --git a/soft-interface.c b/soft-interface.c
+index cfc2cd2..1607844 100644
+--- a/soft-interface.c
++++ b/soft-interface.c
+@@ -235,7 +235,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
+ }
+
+ dhcp_rcp = batadv_gw_dhcp_recipient_get(skb, &header_len,
+- chaddr);
++ chaddr, batadv_gw_get_selected_orig(bat_priv)->orig);
+ /* skb->data may have been modified by
+ * batadv_gw_dhcp_recipient_get()
+ */
+--
+2.4.1
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment