if_pflog: fix packet length
There were two issues with the new pflog packet length. The first is that the length is expected to be a multiple of sizeof(long), but we'd assumed it had to be a multiple of sizeof(uint32_t). The second is that there's some broken software out there (such as Wireshark) that makes incorrect assumptions about the amount of padding. That is, Wireshark assumes there's always three bytes of padding, rather than however much is needed to get to a multiple of sizeof(long). Fix this by adding extra padding, and a fake field to maintain Wireshark's assumption. Reported by: Ozkan KIRIK <ozkan.kirik@gmail.com> Tested by: Ozkan KIRIK <ozkan.kirik@gmail.com> MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D33236
This commit is contained in:
parent
98470f0e0b
commit
6d4baa0d01
@ -31,6 +31,8 @@
|
|||||||
#ifndef _NET_IF_PFLOG_H_
|
#ifndef _NET_IF_PFLOG_H_
|
||||||
#define _NET_IF_PFLOG_H_
|
#define _NET_IF_PFLOG_H_
|
||||||
|
|
||||||
|
#include <net/bpf.h>
|
||||||
|
|
||||||
#define PFLOGIFS_MAX 16
|
#define PFLOGIFS_MAX 16
|
||||||
|
|
||||||
#define PFLOG_RULESET_NAME_SIZE 16
|
#define PFLOG_RULESET_NAME_SIZE 16
|
||||||
@ -51,11 +53,13 @@ struct pfloghdr {
|
|||||||
u_int8_t dir;
|
u_int8_t dir;
|
||||||
u_int8_t pad[3];
|
u_int8_t pad[3];
|
||||||
u_int32_t ridentifier;
|
u_int32_t ridentifier;
|
||||||
|
u_int8_t reserve; /* Appease broken software like Wireshark. */
|
||||||
|
u_int8_t pad2[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PFLOG_HDRLEN sizeof(struct pfloghdr)
|
#define PFLOG_HDRLEN BPF_WORDALIGN(offsetof(struct pfloghdr, pad2))
|
||||||
/* minus pad, also used as a signature */
|
/* minus pad, also used as a signature */
|
||||||
#define PFLOG_REAL_HDRLEN offsetof(struct pfloghdr, pad)
|
#define PFLOG_REAL_HDRLEN offsetof(struct pfloghdr, pad2)
|
||||||
|
|
||||||
#ifdef _KERNEL
|
#ifdef _KERNEL
|
||||||
struct pf_rule;
|
struct pf_rule;
|
||||||
|
@ -215,7 +215,7 @@ pflog_packet(struct pfi_kkif *kif, struct mbuf *m, sa_family_t af, u_int8_t dir,
|
|||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
bzero(&hdr, sizeof(hdr));
|
bzero(&hdr, sizeof(hdr));
|
||||||
hdr.length = PFLOG_HDRLEN;
|
hdr.length = PFLOG_REAL_HDRLEN;
|
||||||
hdr.af = af;
|
hdr.af = af;
|
||||||
hdr.action = rm->action;
|
hdr.action = rm->action;
|
||||||
hdr.reason = reason;
|
hdr.reason = reason;
|
||||||
|
Loading…
Reference in New Issue
Block a user