PF_PACKET filtering hooks for netfilter]
Subsystems (3)
PATCH 1/1 PF_PACKET filtering hooks for netfilter]
JFYI
Signature · 5 lines
Live long and prosper - Harald Welte / [email protected] http://www.gnumonks.org/ ============================================================================ GCS/E/IT d- s-: a-- C+++ UL++++$ P+++ L++++$ E--- W- N++ o? K- w--- O- M+ V-- PS++ PE-- Y++ PGP++ t+ 5-- !X !R tv-- b+++ !DI !D G+ e* h--- r++ y+(*)
Hi all,
The included patch adds two new hooks to the netfilter framework, at the packet level.
With this patch, it is now possible to write filtering modules for non IP/ARP protocols (or even filtering access to user-mode services bound to a packet socket (DHCP, for example...).
It also add the necessary logic to control such modules via setsockopt/getsockopt.
I made two version of this patch : one for 2.4.20-pre5, the other for 2.5.33. I'd be very glad to have some feedback from people trying it, as well as any comment about what is ok and what isn't with this patch.
Thanks a lot,
M.
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.612 -> 1.613
# net/packet/af_packet.c 1.10 -> 1.11
# net/core/dev.c 1.28 -> 1.29
# (new) -> 1.1 include/linux/netfilter_packet.h
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/09/07 [email protected] 1.613
# Implements PF_PACKET netfilter hooks, as well as PF_PACKET
# {get,set}sockopt operations to control modules.
# --------------------------------------------
#
include/linux/netfilter_packet.h new file +17 -0
@@ -0,0 +1,17 @@ +#ifndef __LINUX_NETFILTER_PACKET_H +#define __LINUX_NETFILTER_PACKET_H + +/* PF_PACKET-specific defines for netfilter. +* Written by Marc Zyngier <[email protected]> +* (C)2002 Evidian -- This code is GPL. +*/ + +#include <linux/config.h> +#include <linux/netfilter.h> + +/* PF_PACKET filter hooks */ + +#define NF_PACKET_INPUT 0 +#define NF_PACKET_OUTPUT 1 + +#endif /* __LINUX_NETFILTER_PACKET_H */
net/core/dev.c +62 -47
148 lines not on this page · raw message
net/packet/af_packet.c +14 -0
@@ -77,6 +77,10 @@#include <net/inet_common.h> #endif +#ifdef CONFIG_NETFILTER +#include <linux/netfilter.h> +#endif +#ifdef CONFIG_DLCI extern int dlci_ioctl (unsigned int ,void *);#endif
@@ -1321,7 +1325,12 @@ }#endif default : +#ifdef CONFIG_NETFILTER +return nf_setsockopt (sock->sk,PF_PACKET , optname, optval, + optlen); +#else return -ENOPROTOOPT ; +#endif } }
@@ -1358,7 +1367,12 @@break ; }default : +#ifdef CONFIG_NETFILTER +return nf_getsockopt (sock->sk,PF_PACKET , optname, optval, + optlen); +#else return -ENOPROTOOPT ; +#endif }if (put_user (len, optlen))
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.582 -> 1.583
# net/packet/af_packet.c 1.14 -> 1.15
# net/core/dev.c 1.36 -> 1.37
# (new) -> 1.1 include/linux/netfilter_packet.h
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/09/07 [email protected] 1.583
# Implements PF_PACKET netfilter hooks, as well as PF_PACKET
# {get,set}sockopt operations to control modules.
# --------------------------------------------
#
include/linux/netfilter_packet.h new file +17 -0
@@ -0,0 +1,17 @@ +#ifndef __LINUX_NETFILTER_PACKET_H +#define __LINUX_NETFILTER_PACKET_H + +/* PF_PACKET-specific defines for netfilter. +* Written by Marc Zyngier <[email protected]> +* (C)2002 Evidian -- This code is GPL. +*/ + +#include <linux/config.h> +#include <linux/netfilter.h> + +/* PF_PACKET filter hooks */ + +#define NF_PACKET_INPUT 0 +#define NF_PACKET_OUTPUT 1 + +#endif /* __LINUX_NETFILTER_PACKET_H */
net/core/dev.c +63 -44
152 lines not on this page · raw message
net/packet/af_packet.c +14 -0
@@ -77,6 +77,10 @@#include <net/inet_common.h> #endif +#ifdef CONFIG_NETFILTER +#include <linux/netfilter.h> +#endif +#ifdef CONFIG_DLCI extern int dlci_ioctl (unsigned int ,void *);#endif
@@ -1333,7 +1337,12 @@ }#endif default : +#ifdef CONFIG_NETFILTER +return nf_setsockopt (sock->sk,PF_PACKET , optname, optval, + optlen); +#else return -ENOPROTOOPT ; +#endif } }
@@ -1371,7 +1380,12 @@break ; }default : +#ifdef CONFIG_NETFILTER +return nf_getsockopt (sock->sk,PF_PACKET , optname, optval, + optlen); +#else return -ENOPROTOOPT ; +#endif }if (put_user (len, optlen))
Signature · 1 line
Places change, faces change. Life is so very strange.