Skip to contentSkip to conversation

libnetfilter_queue: align the buffer passed to nfnl_fill_hdr

PATCH In review Silvester Erdeg 2 participants 2 messages Jan 27, 2008 – Feb 19, 2008 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libnetfilter_queue: align the buffer passed to nfnl_fill_hdr

The buffer passed to nfnl_fill_hdr needs to aligned because some architectures (e.g. ARM) cannot do proper 32-bit read/writes on unaligned addresses. This patch solves this for libnetfilter_queue.

diff -uNpr libnetfilter_queue-0.0.15-orig/src/libnetfilter_queue.c libnetfilter_queue-0.0.15/src/libnetfilter_queue.c
--- libnetfilter_queue-0.0.15-orig/src/libnetfilter_queue.c 2007-03-22
00:49:46.000000000 +0100
+++ libnetfilter_queue-0.0.15/src/libnetfilter_queue.c 2008-01-08
14:50:53.000000000 +0100
@@ -98,7 +98,7 @@ __build_send_cfg_msg(struct nfq_handle *
u_int16_t queuenum, u_int16_t pf)
{
char buf[NFNL_HEADER_LEN
- +NFA_LENGTH(sizeof(struct nfqnl_msg_config_cmd))];
+ +NFA_LENGTH(sizeof(struct nfqnl_msg_config_cmd))] __attribute__((aligned));
struct nfqnl_msg_config_cmd cmd;
struct nlmsghdr *nmh = (struct nlmsghdr *) buf;

@@ -273,7 +273,7 @@ int nfq_set_mode(struct nfq_q_handle *qh
u_int8_t mode, u_int32_t range)
{
char buf[NFNL_HEADER_LEN
- +NFA_LENGTH(sizeof(struct nfqnl_msg_config_params))];
+ +NFA_LENGTH(sizeof(struct nfqnl_msg_config_params))]
__attribute__((aligned));
struct nfqnl_msg_config_params params; struct nlmsghdr *nmh = (struct nlmsghdr *) buf;

@@ -292,7 +292,7 @@ int nfq_set_queue_maxlen(struct nfq_q_ha
u_int32_t queuelen)
{
char buf[NFNL_HEADER_LEN
- +NFA_LENGTH(sizeof(struct nfqnl_msg_config_params))];
+ +NFA_LENGTH(sizeof(struct nfqnl_msg_config_params))]
__attribute__((aligned));
u_int32_t queue_maxlen = htonl(queuelen); struct nlmsghdr *nmh = (struct nlmsghdr *) buf;

@@ -312,7 +312,7 @@ static int __set_verdict(struct nfq_q_ha
struct nfqnl_msg_verdict_hdr vh;
char buf[NFNL_HEADER_LEN
+NFA_LENGTH(sizeof(mark))
- +NFA_LENGTH(sizeof(vh))];
+ +NFA_LENGTH(sizeof(vh))] __attribute__((aligned));
struct nlmsghdr *nmh = (struct nlmsghdr *) buf;

struct iovec iov[3];

#1 lore raw
Quoted 3 lines · Silvester Erdeg

The buffer passed to nfnl_fill_hdr needs to aligned because some architectures (e.g. ARM) cannot do proper 32-bit read/writes on unaligned addresses. This patch solves this for libnetfilter_queue.

This does not apply cleanly because your mailer seems to have wrapped long lines. Could you resend as attachment?