Re: your mail

Richard B. Johnson (root@chaos.analogic.com)
Sun, 7 Mar 1999 11:11:08 -0500 (EST)


On Sun, 7 Mar 1999, Urmane Hendrake wrote:

> Hey, is it just me, or is CONFIG_FILTER broken in vanilla 2.2.2?
> I get a wad of syntax errors in net/sock.h; looks like there's some
> confusion between the defs for sk_filter and sock_filter.
>
> ... or maybe it's me that's confused ...
>
This is getting to be a FAQ. Here is the patch:

*** include/linux/filter.h.orig Tue Feb 23 16:58:17 1999
--- include/linux/filter.h Tue Feb 23 17:10:13 1999
***************
*** 30,35 ****
--- 30,49 ----
struct sock_filter *filter;
};

+ #ifdef __KERNEL__
+ struct sk_filter
+ {
+ atomic_t refcnt;
+ unsigned int len; /* Number of filter blocks */
+ struct sock_filter insns[0];
+ };
+
+ extern __inline__ unsigned int sk_filter_len(struct sk_filter *fp)
+ {
+ return fp->len*sizeof(struct sock_filter) + sizeof(*fp);
+ }
+ #endif
+
/*
* Instruction classes
*/
***************
*** 86,106 ****
#define BPF_TAX 0x00
#define BPF_TXA 0x80

! #define BPF_MAXINSNS 512

/*
* Macros for filter block array initializers.
*/
#define BPF_STMT(code, k) { (unsigned short)(code), 0, 0, k }
#define BPF_JUMP(code, k, jt, jf) { (unsigned short)(code), jt, jf, k }

/*
* Number of scratch memory words for: BPF_ST and BPF_STX
*/
#define BPF_MEMWORDS 16

#ifdef __KERNEL__
! extern int sk_run_filter(unsigned char *data, int len, struct sock_filter *filter, int flen);
extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk);
#endif /* __KERNEL__ */

--- 100,139 ----
#define BPF_TAX 0x00
#define BPF_TXA 0x80

! #ifndef BPF_MAXINSNS
! #define BPF_MAXINSNS 4096
! #endif

/*
* Macros for filter block array initializers.
*/
+ #ifndef BPF_STMT
#define BPF_STMT(code, k) { (unsigned short)(code), 0, 0, k }
+ #endif
+ #ifndef BPF_JUMP
#define BPF_JUMP(code, k, jt, jf) { (unsigned short)(code), jt, jf, k }
+ #endif

/*
* Number of scratch memory words for: BPF_ST and BPF_STX
*/
#define BPF_MEMWORDS 16

+ /* RATIONALE. Negative offsets are invalid in BPF.
+ We use them to reference ancillary data.
+ Unlike introduction new instructions, it does not break
+ existing compilers/optimizers.
+ */
+ #define SKF_AD_OFF (-0x1000)
+ #define SKF_AD_PROTOCOL 0
+ #define SKF_AD_PKTTYPE 4
+ #define SKF_AD_IFINDEX 8
+ #define SKF_AD_MAX 12
+ #define SKF_NET_OFF (-0x100000)
+ #define SKF_LL_OFF (-0x200000)
+
#ifdef __KERNEL__
! extern int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen);
extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk);
#endif /* __KERNEL__ */

Cheers,
Dick Johnson
***** FILE SYSTEM WAS MODIFIED *****
Penguin : Linux version 2.2.2 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.
Bait : plutonium Cuba president assassination killed Iran Honduras
nitrate tritium toluene ammonium subway 747 pits iodine critical nuclear

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/