This reverts commit 9048eb62124f47f66d12eb1d706ab5fb265553f7.
This fix can be implemented using the nf_Reset() helper
instead of partly reimplementing it with a batman-adv
private function.
Signed-off-by: Antonio Quartulli <antonio(a)meshcoding.com>
---
soft-interface.c | 8 --------
soft-interface.h | 16 ----------------
2 files changed, 24 deletions(-)
diff --git a/soft-interface.c b/soft-interface.c
index 5dd1247..33b6144 100644
--- a/soft-interface.c
+++ b/soft-interface.c
@@ -371,14 +371,6 @@ void batadv_interface_rx(struct net_device *soft_iface,
if (batadv_is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest))
goto dropped;
- /* Clean the netfilter state before delivering the skb.
- * This packet may have traversed a bridge when it was encapsulated into
- * the batman header. Now that the header has been removed, the
- * netfilter state must be cleaned up to avoid to mess up with a
- * possible second bridge
- */
- batadv_nf_bridge_skb_free(skb);
-
netif_rx(skb);
goto out;
diff --git a/soft-interface.h b/soft-interface.h
index 5c19c42..2f2472c 100644
--- a/soft-interface.h
+++ b/soft-interface.h
@@ -29,20 +29,4 @@ void batadv_softif_destroy_sysfs(struct net_device *soft_iface);
int batadv_softif_is_valid(const struct net_device *net_dev);
extern struct rtnl_link_ops batadv_link_ops;
-#ifdef CONFIG_BRIDGE_NETFILTER
-/**
- * batadv_nf_bridge_skb_free - clean the NF bridge data in an skb
- * @skb: the skb which nf data has to be free'd
- */
-static inline void batadv_nf_bridge_skb_free(struct sk_buff *skb)
-{
- nf_bridge_put(skb->nf_bridge);
- skb->nf_bridge = NULL;
-}
-#else
-static inline void batadv_nf_bridge_skb_free(struct sk_buff *skb)
-{
-}
-#endif /* CONFIG_BRIDGE_NETFILTER */
-
#endif /* _NET_BATMAN_ADV_SOFT_INTERFACE_H_ */
--
1.8.5.2
Hello David,
this is a pull request intended for net.
Patch 1 is fixing a bug that is present in the batman-adv code since a while.
The bug prevents a batman-adv encapsulated packet from being correctly
processed by "Netfilter Bridge" twice. In particular a packet that
first enters a bridge with the batman-adv header and then enters another bridge
after the header has been removed is improperly processed. The problem is due to
the skb->nf_bridge member not being cleaned when the batman-adv header is
removed.
This patch takes care of properly releasing the nf_bridge field at the right
time (like all the other tunneling protocol do).
** Please, enqueue this patch for stable.
Patches from 2 to 6 take care of reshaping the packet layout a little bit to
make sure that all the structures we use for sending messages have size multiple
of 4 (or 2 when pack(2) is used).
This solves the problem raised by Russel King about the static checks failure
when compiling the module on the ARM architecture.
Please pull or let me know of any problem.
Thank you,
Antonio
The following changes since commit 58a4782449c5882f61882396ef18cc34c7dc1269:
ipv6: sit: update mtu check to take care of gso packets (2013-12-18 17:55:24 -0500)
are available in the git repository at:
git://git.open-mesh.org/linux-merge.git tags/batman-adv-fix-for-davem
for you to fetch changes up to 128cfa6a586154581ce1b891baf929810117a82a:
batman-adv: fix alignment for batadv_tvlv_tt_change (2013-12-19 00:27:24 +0100)
----------------------------------------------------------------
Included changes:
- release skb->nf_bridge when removing the batman-adv header
from an incoming packet. This prevents netfilter bridge
from being fooled when the same packet enters a bridge
twice (or more): the first time within the batman-adv
header and the second time without.
- adjust the packet layout to prevent any architecture from
adding padding bytes. All the structs sent over the wire
now have size multiple of 4bytes (unless pack(2) is used).
----------------------------------------------------------------
Antonio Quartulli (3):
batman-adv: free nf_bridge member on locally delivered skb
batman-adv: fix size of batadv_icmp_header
batman-adv: fix alignment for batadv_tvlv_tt_change
Simon Wunderlich (3):
batman-adv: fix alignment for batadv_coded_packet
batman-adv: fix header alignment by unrolling batadv_header
batman-adv: fix size of batadv_bla_claim_dst
net/batman-adv/bat_iv_ogm.c | 36 +++++-----
net/batman-adv/distributed-arp-table.c | 6 +-
net/batman-adv/fragmentation.c | 8 +--
net/batman-adv/icmp_socket.c | 6 +-
net/batman-adv/main.c | 16 ++---
net/batman-adv/network-coding.c | 22 +++---
net/batman-adv/packet.h | 124 +++++++++++++++++++++++++--------
net/batman-adv/routing.c | 30 ++++----
net/batman-adv/send.c | 10 +--
net/batman-adv/soft-interface.c | 19 +++--
net/batman-adv/soft-interface.h | 16 +++++
net/batman-adv/translation-table.c | 6 +-
12 files changed, 195 insertions(+), 104 deletions(-)
The compiler may decide to pad the structure, and then it does not
have the expected size of 46 byte. Fix this by moving it in the
pragma pack(2) part of the code.
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
---
packet.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/packet.h b/packet.h
index 207459b..10597a6 100644
--- a/packet.h
+++ b/packet.h
@@ -315,8 +315,6 @@ struct batadv_bcast_packet {
*/
};
-#pragma pack()
-
/**
* struct batadv_coded_packet - network coded packet
* @header: common batman packet header and ttl of first included packet
@@ -349,6 +347,8 @@ struct batadv_coded_packet {
__be16 coded_len;
};
+#pragma pack()
+
/**
* struct batadv_unicast_tvlv - generic unicast packet with tvlv payload
* @header: common batman packet header
--
1.7.10.4
struct batadv_icmp_header currently has a size of 17, which
will be padded to 20 on some architectures. Fix this by
unrolling the header into the parent structures.
Moreover keep the ICMP parsing functions as generic as they
are now by using a stub icmp_header struct during packet
parsing.
Signed-off-by: Antonio Quartulli <antonio(a)meshcoding.com>
---
Changes from v2:
- readded comment next to msg_type memeber
main.c | 4 ++--
packet.h | 40 +++++++++++++++++++++++++++++++++++-----
routing.c | 14 +++++++-------
3 files changed, 44 insertions(+), 14 deletions(-)
diff --git a/main.c b/main.c
index d87778b..1511f64 100644
--- a/main.c
+++ b/main.c
@@ -426,8 +426,8 @@ static void batadv_recv_handler_init(void)
BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, dest) != 4);
BUILD_BUG_ON(offsetof(struct batadv_unicast_tvlv_packet, dst) != 4);
BUILD_BUG_ON(offsetof(struct batadv_frag_packet, dest) != 4);
- BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, icmph.dst) != 4);
- BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, icmph.dst) != 4);
+ BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, dst) != 4);
+ BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, dst) != 4);
/* broadcast packet */
batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet;
diff --git a/packet.h b/packet.h
index 175ce7d..2a857ed 100644
--- a/packet.h
+++ b/packet.h
@@ -191,7 +191,7 @@ struct batadv_ogm_packet {
#define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet)
/**
- * batadv_icmp_header - common ICMP header
+ * batadv_icmp_header - common members among all the ICMP packets
* @packet_type: batman-adv packet type, part of the general header
* @version: batman-adv protocol version, part of the genereal header
* @ttl: time to live for this packet, part of the genereal header
@@ -199,6 +199,11 @@ struct batadv_ogm_packet {
* @dst: address of the destination node
* @orig: address of the source node
* @uid: local ICMP socket identifier
+ * @align: not used - useful for alignment purposes only
+ *
+ * This structure is used for ICMP packets parsing only and it is never sent
+ * over the wire. The alignment field at the end is there to ensure that
+ * members are padded the same way as they are in real packets.
*/
struct batadv_icmp_header {
uint8_t packet_type;
@@ -208,16 +213,29 @@ struct batadv_icmp_header {
uint8_t dst[ETH_ALEN];
uint8_t orig[ETH_ALEN];
uint8_t uid;
+ uint8_t align[3];
};
/**
* batadv_icmp_packet - ICMP packet
- * @icmph: common ICMP header
+ * @packet_type: batman-adv packet type, part of the general header
+ * @version: batman-adv protocol version, part of the genereal header
+ * @ttl: time to live for this packet, part of the genereal header
+ * @msg_type: ICMP packet type
+ * @dst: address of the destination node
+ * @orig: address of the source node
+ * @uid: local ICMP socket identifier
* @reserved: not used - useful for alignment
* @seqno: ICMP sequence number
*/
struct batadv_icmp_packet {
- struct batadv_icmp_header icmph;
+ uint8_t packet_type;
+ uint8_t version;
+ uint8_t ttl;
+ uint8_t msg_type; /* see ICMP message types above */
+ uint8_t dst[ETH_ALEN];
+ uint8_t orig[ETH_ALEN];
+ uint8_t uid;
uint8_t reserved;
__be16 seqno;
};
@@ -226,13 +244,25 @@ struct batadv_icmp_packet {
/**
* batadv_icmp_packet_rr - ICMP RouteRecord packet
- * @icmph: common ICMP header
+ * @packet_type: batman-adv packet type, part of the general header
+ * @version: batman-adv protocol version, part of the genereal header
+ * @ttl: time to live for this packet, part of the genereal header
+ * @msg_type: ICMP packet type
+ * @dst: address of the destination node
+ * @orig: address of the source node
+ * @uid: local ICMP socket identifier
* @rr_cur: number of entries the rr array
* @seqno: ICMP sequence number
* @rr: route record array
*/
struct batadv_icmp_packet_rr {
- struct batadv_icmp_header icmph;
+ uint8_t packet_type;
+ uint8_t version;
+ uint8_t ttl;
+ uint8_t msg_type; /* see ICMP message types above */
+ uint8_t dst[ETH_ALEN];
+ uint8_t orig[ETH_ALEN];
+ uint8_t uid;
uint8_t rr_cur;
__be16 seqno;
uint8_t rr[BATADV_RR_LEN][ETH_ALEN];
diff --git a/routing.c b/routing.c
index 5b52d71..46278bf 100644
--- a/routing.c
+++ b/routing.c
@@ -338,9 +338,9 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
icmp_packet = (struct batadv_icmp_packet *)skb->data;
/* send TTL exceeded if packet is an echo request (traceroute) */
- if (icmp_packet->icmph.msg_type != BATADV_ECHO_REQUEST) {
+ if (icmp_packet->msg_type != BATADV_ECHO_REQUEST) {
pr_debug("Warning - can't forward icmp packet from %pM to %pM: ttl exceeded\n",
- icmp_packet->icmph.orig, icmp_packet->icmph.dst);
+ icmp_packet->orig, icmp_packet->dst);
goto out;
}
@@ -349,7 +349,7 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
goto out;
/* get routing information */
- orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->icmph.orig);
+ orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->orig);
if (!orig_node)
goto out;
@@ -359,11 +359,11 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
icmp_packet = (struct batadv_icmp_packet *)skb->data;
- memcpy(icmp_packet->icmph.dst, icmp_packet->icmph.orig, ETH_ALEN);
- memcpy(icmp_packet->icmph.orig, primary_if->net_dev->dev_addr,
+ memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
+ memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr,
ETH_ALEN);
- icmp_packet->icmph.msg_type = BATADV_TTL_EXCEEDED;
- icmp_packet->icmph.ttl = BATADV_TTL;
+ icmp_packet->msg_type = BATADV_TTL_EXCEEDED;
+ icmp_packet->ttl = BATADV_TTL;
if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP)
ret = NET_RX_SUCCESS;
--
1.8.4.4
alfred will refuse to start if bat0 doesn't exist yet
root@48cfeb:~# alfred -i br-lan -m -b bat0
Could not find transtable_global for interface bat0. Make sure it is a
valid batman-adv soft-interface
at boot time this can create a race condition, since wifi interfaces can
take longer to be brought up, making bat0 appear much later than the
time alfred init.d script is run. In the following example, 4 seconds later.
Sun Nov 3 05:09:13 2013 kern.emerg /etc/rc.d/S99alfred: starting alfred
Sun Nov 3 05:09:13 2013 kern.emerg /etc/rc.d/S99alfred: starting batadv-vis
Sun Nov 3 05:09:13 2013 kern.emerg can't connect to unix socket:
Connection refused
Sun Nov 3 05:09:13 2013 kern.emerg can't connect to unix socket:
Connection refused
Sun Nov 3 05:09:17 2013 kern.info kernel: [ 28.620000] batman_adv:
bat0: Adding interface: wlan0ah.145
Sun Nov 3 05:09:17 2013 kern.info kernel: [ 28.620000] batman_adv:
bat0: Interface activated: wlan0ah.145
Sun Nov 3 05:09:17 2013 daemon.notice netifd: Interface
'lm_wlan0ah_bata' is now up
Sun Nov 3 05:09:17 2013 kern.info kernel: [ 29.060000] batman_adv:
bat0: bridge_loop_avoidance: Changing from: disabled to: enabled
Sun Nov 3 05:09:17 2013 kern.info kernel: [ 29.080000] batman_adv:
bat0: distributed_arp_table: Changing from: enabled to: disabled
sending a patch for this in a minute, along with another bugfix which
needs less explanation :)
Many uses of the return value of seq_printf/seq_puts/seq_putc are
incorrect. Many assume that the return value is the number of
chars emitted into a buffer like printf/puts/putc.
It would be better to make the return value of these functions void
to avoid these misuses.
Start to do so.
Convert seq_overflow to a public function from a static function.
Remove the return uses of seq_printf/seq_puts/seq_putc from net.
Add a seq_overflow function call instead.
Joe Perches (3):
seq: Add a seq_overflow test.
batman-adv: Use seq_overflow
netfilter: Use seq_overflow
fs/seq_file.c | 15 ++++----
include/linux/seq_file.h | 2 +
include/net/netfilter/nf_conntrack_acct.h | 3 +-
net/batman-adv/gateway_client.c | 25 ++++++------
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 6 ++-
.../netfilter/nf_conntrack_l3proto_ipv4_compat.c | 42 +++++++++++++--------
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 6 ++-
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 10 +++--
net/netfilter/nf_conntrack_acct.c | 11 +++---
net/netfilter/nf_conntrack_expect.c | 4 +-
net/netfilter/nf_conntrack_proto_dccp.c | 12 ++++--
net/netfilter/nf_conntrack_proto_gre.c | 15 +++++---
net/netfilter/nf_conntrack_proto_sctp.c | 12 ++++--
net/netfilter/nf_conntrack_proto_tcp.c | 11 ++++--
net/netfilter/nf_conntrack_proto_udp.c | 7 ++--
net/netfilter/nf_conntrack_proto_udplite.c | 7 ++--
net/netfilter/nf_conntrack_standalone.c | 44 +++++++++++++---------
net/netfilter/nf_log.c | 26 ++++++-------
net/netfilter/nfnetlink_log.c | 12 +++---
net/netfilter/nfnetlink_queue_core.c | 14 ++++---
net/netfilter/x_tables.c | 8 ++--
net/netfilter/xt_hashlimit.c | 34 +++++++++--------
22 files changed, 191 insertions(+), 135 deletions(-)
--
1.8.1.2.459.gbcd45b4.dirty