Blame SOURCES/0003-More-descriptive-name-for-bpf_filter1.patch

9b1536
From e58e6b25c82cc2f76f08b291e14f4e81f4ae1364 Mon Sep 17 00:00:00 2001
9b1536
From: Guy Harris <guy@alum.mit.edu>
9b1536
Date: Wed, 5 Nov 2014 11:18:51 -0800
9b1536
Subject: [PATCH 3/3] More descriptive name for bpf_filter1().
9b1536
9b1536
Call it bpf_filter_with_aux_data(), to better indicate what it does.
9b1536
9b1536
Also expand some comments and clean up white space a bit.
9b1536
9b1536
(cherry picked from 20119d41be224cf9ea821155ad0b267f7e40f234)
9b1536
9b1536
Conflicts:
9b1536
        pcap-linux.c
9b1536
---
9b1536
 bpf/net/bpf_filter.c | 7 +++++--
9b1536
 pcap-linux.c         | 7 +++----
9b1536
 pcap/bpf.h           | 7 ++++++-
9b1536
 3 files changed, 14 insertions(+), 7 deletions(-)
9b1536
9b1536
diff --git a/bpf/net/bpf_filter.c b/bpf/net/bpf_filter.c
9b1536
index 3409a9b..307f980 100644
9b1536
--- a/bpf/net/bpf_filter.c
9b1536
+++ b/bpf/net/bpf_filter.c
9b1536
@@ -215,11 +215,14 @@ enum {
9b1536
  * Execute the filter program starting at pc on the packet p
9b1536
  * wirelen is the length of the original packet
9b1536
  * buflen is the amount of data present
9b1536
+ * aux_data is auxiliary data, currently used only when interpreting
9b1536
+ * filters intended for the Linux kernel in cases where the kernel
9b1536
+ * rejects the filter; it contains VLAN tag information
9b1536
  * For the kernel, p is assumed to be a pointer to an mbuf if buflen is 0,
9b1536
  * in all other cases, p is a pointer to a buffer and buflen is its size.
9b1536
  */
9b1536
 u_int
9b1536
-bpf_filter1(pc, p, wirelen, buflen, aux_data)
9b1536
+bpf_filter_with_aux_data(pc, p, wirelen, buflen, aux_data)
9b1536
 	register const struct bpf_insn *pc;
9b1536
 	register const u_char *p;
9b1536
 	u_int wirelen;
9b1536
@@ -579,7 +582,7 @@ bpf_filter(pc, p, wirelen, buflen)
9b1536
 	u_int wirelen;
9b1536
 	register u_int buflen;
9b1536
 {
9b1536
-	return bpf_filter1(pc, p, wirelen, buflen, NULL);
9b1536
+	return bpf_filter_with_aux_data(pc, p, wirelen, buflen, NULL);
9b1536
 }
9b1536
 
9b1536
 
9b1536
diff --git a/pcap-linux.c b/pcap-linux.c
9b1536
index 68e6d05..a370858 100644
9b1536
--- a/pcap-linux.c
9b1536
+++ b/pcap-linux.c
9b1536
@@ -1708,9 +1708,8 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
9b1536
 
9b1536
 	/* Run the packet filter if not using kernel filter */
9b1536
 	if (handlep->filter_in_userland && handle->fcode.bf_insns) {
9b1536
-		if (bpf_filter1(handle->fcode.bf_insns, bp,
9b1536
-		                packet_len, caplen, &aux_data) == 0)
9b1536
-		{
9b1536
+		if (bpf_filter_with_aux_data(handle->fcode.bf_insns, bp,
9b1536
+		    packet_len, caplen, &aux_data) == 0) {
9b1536
 			/* rejected by filter */
9b1536
 			return 0;
9b1536
 		}
9b1536
@@ -4282,7 +4281,7 @@ static int pcap_handle_packet_mmap(
9b1536
                 aux_data.vlan_tag = tp_vlan_tci & 0x0fff;
9b1536
                 aux_data.vlan_tag_present = tp_vlan_tci_valid;
9b1536
 
9b1536
-                if (bpf_filter1(handle->fcode.bf_insns, bp, tp_len, tp_snaplen, &aux_data) == 0)
9b1536
+                if (bpf_filter_with_aux_data(handle->fcode.bf_insns, bp, tp_len, tp_snaplen, &aux_data) == 0)
9b1536
                         return 0;
9b1536
         }
9b1536
 
9b1536
diff --git a/pcap/bpf.h b/pcap/bpf.h
9b1536
index 495f326..29efd7e 100644
9b1536
--- a/pcap/bpf.h
9b1536
+++ b/pcap/bpf.h
9b1536
@@ -1320,6 +1320,11 @@ struct bpf_insn {
9b1536
 	bpf_u_int32 k;
9b1536
 };
9b1536
 
9b1536
+/*
9b1536
+ * Auxiliary data, for use when interpreting a filter intended for the
9b1536
+ * Linux kernel when the kernel rejects the filter (requiring us to
9b1536
+ * run it in userland).  It contains VLAN tag information.
9b1536
+ */
9b1536
 struct bpf_aux_data {
9b1536
         uint16_t vlan_tag_present;
9b1536
         uint16_t vlan_tag;
9b1536
@@ -1334,7 +1339,7 @@ struct bpf_aux_data {
9b1536
 #if __STDC__ || defined(__cplusplus)
9b1536
 extern int bpf_validate(const struct bpf_insn *, int);
9b1536
 extern u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
9b1536
-extern u_int bpf_filter1(const struct bpf_insn *, const u_char *, u_int, u_int, const struct bpf_aux_data *);        
9b1536
+extern u_int bpf_filter_with_aux_data(const struct bpf_insn *, const u_char *, u_int, u_int, const struct bpf_aux_data *);        
9b1536
 #else
9b1536
 extern int bpf_validate();
9b1536
 extern u_int bpf_filter();
9b1536
-- 
9b1536
2.4.3
9b1536