@@ -659,10 +659,10 @@ static struct block *gen_linktype(compiler_state_t *, bpf_u_int32);
659
659
static struct block * gen_snap (compiler_state_t * , bpf_u_int32 , bpf_u_int32 );
660
660
static struct block * gen_llc_linktype (compiler_state_t * , bpf_u_int32 );
661
661
static struct block * gen_hostop (compiler_state_t * , bpf_u_int32 , bpf_u_int32 ,
662
- int , bpf_u_int32 , u_int , u_int );
662
+ int , u_int , u_int );
663
663
#ifdef INET6
664
664
static struct block * gen_hostop6 (compiler_state_t * , struct in6_addr * ,
665
- struct in6_addr * , int , bpf_u_int32 , u_int , u_int );
665
+ struct in6_addr * , int , u_int , u_int );
666
666
#endif
667
667
static struct block * gen_ahostop (compiler_state_t * , const uint8_t , int );
668
668
static struct block * gen_ehostop (compiler_state_t * , const u_char * , int );
@@ -4174,7 +4174,7 @@ gen_llc_linktype(compiler_state_t *cstate, bpf_u_int32 ll_proto)
4174
4174
4175
4175
static struct block *
4176
4176
gen_hostop (compiler_state_t * cstate , bpf_u_int32 addr , bpf_u_int32 mask ,
4177
- int dir , bpf_u_int32 ll_proto , u_int src_off , u_int dst_off )
4177
+ int dir , u_int src_off , u_int dst_off )
4178
4178
{
4179
4179
struct block * b0 , * b1 ;
4180
4180
u_int offset ;
@@ -4190,15 +4190,15 @@ gen_hostop(compiler_state_t *cstate, bpf_u_int32 addr, bpf_u_int32 mask,
4190
4190
break ;
4191
4191
4192
4192
case Q_AND :
4193
- b0 = gen_hostop (cstate , addr , mask , Q_SRC , ll_proto , src_off , dst_off );
4194
- b1 = gen_hostop (cstate , addr , mask , Q_DST , ll_proto , src_off , dst_off );
4193
+ b0 = gen_hostop (cstate , addr , mask , Q_SRC , src_off , dst_off );
4194
+ b1 = gen_hostop (cstate , addr , mask , Q_DST , src_off , dst_off );
4195
4195
gen_and (b0 , b1 );
4196
4196
return b1 ;
4197
4197
4198
4198
case Q_DEFAULT :
4199
4199
case Q_OR :
4200
- b0 = gen_hostop (cstate , addr , mask , Q_SRC , ll_proto , src_off , dst_off );
4201
- b1 = gen_hostop (cstate , addr , mask , Q_DST , ll_proto , src_off , dst_off );
4200
+ b0 = gen_hostop (cstate , addr , mask , Q_SRC , src_off , dst_off );
4201
+ b1 = gen_hostop (cstate , addr , mask , Q_DST , src_off , dst_off );
4202
4202
gen_or (b0 , b1 );
4203
4203
return b1 ;
4204
4204
@@ -4230,17 +4230,13 @@ gen_hostop(compiler_state_t *cstate, bpf_u_int32 addr, bpf_u_int32 mask,
4230
4230
abort ();
4231
4231
/*NOTREACHED*/
4232
4232
}
4233
- b0 = gen_linktype (cstate , ll_proto );
4234
- b1 = gen_mcmp (cstate , OR_LINKPL , offset , BPF_W , addr , mask );
4235
- gen_and (b0 , b1 );
4236
- return b1 ;
4233
+ return gen_mcmp (cstate , OR_LINKPL , offset , BPF_W , addr , mask );
4237
4234
}
4238
4235
4239
4236
#ifdef INET6
4240
4237
static struct block *
4241
4238
gen_hostop6 (compiler_state_t * cstate , struct in6_addr * addr ,
4242
- struct in6_addr * mask , int dir , bpf_u_int32 ll_proto , u_int src_off ,
4243
- u_int dst_off )
4239
+ struct in6_addr * mask , int dir , u_int src_off , u_int dst_off )
4244
4240
{
4245
4241
struct block * b0 , * b1 ;
4246
4242
u_int offset ;
@@ -4266,15 +4262,15 @@ gen_hostop6(compiler_state_t *cstate, struct in6_addr *addr,
4266
4262
break ;
4267
4263
4268
4264
case Q_AND :
4269
- b0 = gen_hostop6 (cstate , addr , mask , Q_SRC , ll_proto , src_off , dst_off );
4270
- b1 = gen_hostop6 (cstate , addr , mask , Q_DST , ll_proto , src_off , dst_off );
4265
+ b0 = gen_hostop6 (cstate , addr , mask , Q_SRC , src_off , dst_off );
4266
+ b1 = gen_hostop6 (cstate , addr , mask , Q_DST , src_off , dst_off );
4271
4267
gen_and (b0 , b1 );
4272
4268
return b1 ;
4273
4269
4274
4270
case Q_DEFAULT :
4275
4271
case Q_OR :
4276
- b0 = gen_hostop6 (cstate , addr , mask , Q_SRC , ll_proto , src_off , dst_off );
4277
- b1 = gen_hostop6 (cstate , addr , mask , Q_DST , ll_proto , src_off , dst_off );
4272
+ b0 = gen_hostop6 (cstate , addr , mask , Q_SRC , src_off , dst_off );
4273
+ b1 = gen_hostop6 (cstate , addr , mask , Q_DST , src_off , dst_off );
4278
4274
gen_or (b0 , b1 );
4279
4275
return b1 ;
4280
4276
@@ -4316,8 +4312,6 @@ gen_hostop6(compiler_state_t *cstate, struct in6_addr *addr,
4316
4312
gen_and (b0 , b1 );
4317
4313
b0 = gen_mcmp (cstate , OR_LINKPL , offset + 0 , BPF_W , ntohl (a [0 ]), ntohl (m [0 ]));
4318
4314
gen_and (b0 , b1 );
4319
- b0 = gen_linktype (cstate , ll_proto );
4320
- gen_and (b0 , b1 );
4321
4315
return b1 ;
4322
4316
}
4323
4317
#endif
@@ -5182,13 +5176,22 @@ gen_host(compiler_state_t *cstate, bpf_u_int32 addr, bpf_u_int32 mask,
5182
5176
bpf_error (cstate , "link-layer modifier applied to %s" , typestr );
5183
5177
5184
5178
case Q_IP :
5185
- return gen_hostop (cstate , addr , mask , dir , ETHERTYPE_IP , 12 , 16 );
5179
+ b0 = gen_linktype (cstate , ETHERTYPE_IP );
5180
+ b1 = gen_hostop (cstate , addr , mask , dir , 12 , 16 );
5181
+ gen_and (b0 , b1 );
5182
+ return b1 ;
5186
5183
5187
5184
case Q_RARP :
5188
- return gen_hostop (cstate , addr , mask , dir , ETHERTYPE_REVARP , 14 , 24 );
5185
+ b0 = gen_linktype (cstate , ETHERTYPE_REVARP );
5186
+ b1 = gen_hostop (cstate , addr , mask , dir , 14 , 24 );
5187
+ gen_and (b0 , b1 );
5188
+ return b1 ;
5189
5189
5190
5190
case Q_ARP :
5191
- return gen_hostop (cstate , addr , mask , dir , ETHERTYPE_ARP , 14 , 24 );
5191
+ b0 = gen_linktype (cstate , ETHERTYPE_ARP );
5192
+ b1 = gen_hostop (cstate , addr , mask , dir , 14 , 24 );
5193
+ gen_and (b0 , b1 );
5194
+ return b1 ;
5192
5195
5193
5196
case Q_SCTP :
5194
5197
bpf_error (cstate , "'sctp' modifier applied to %s" , typestr );
@@ -5309,6 +5312,7 @@ static struct block *
5309
5312
gen_host6 (compiler_state_t * cstate , struct in6_addr * addr ,
5310
5313
struct in6_addr * mask , int proto , int dir , int type )
5311
5314
{
5315
+ struct block * b0 , * b1 ;
5312
5316
const char * typestr ;
5313
5317
5314
5318
if (type == Q_NET )
@@ -5319,7 +5323,11 @@ gen_host6(compiler_state_t *cstate, struct in6_addr *addr,
5319
5323
switch (proto ) {
5320
5324
5321
5325
case Q_DEFAULT :
5322
- return gen_host6 (cstate , addr , mask , Q_IPV6 , dir , type );
5326
+ case Q_IPV6 :
5327
+ b0 = gen_linktype (cstate , ETHERTYPE_IPV6 );
5328
+ b1 = gen_hostop6 (cstate , addr , mask , dir , 8 , 24 );
5329
+ gen_and (b0 , b1 );
5330
+ return b1 ;
5323
5331
5324
5332
case Q_LINK :
5325
5333
bpf_error (cstate , "link-layer modifier applied to ip6 %s" , typestr );
@@ -5369,9 +5377,6 @@ gen_host6(compiler_state_t *cstate, struct in6_addr *addr,
5369
5377
case Q_MOPDL :
5370
5378
bpf_error (cstate , "'mopdl' modifier applied to ip6 %s" , typestr );
5371
5379
5372
- case Q_IPV6 :
5373
- return gen_hostop6 (cstate , addr , mask , dir , ETHERTYPE_IPV6 , 8 , 24 );
5374
-
5375
5380
case Q_ICMPV6 :
5376
5381
bpf_error (cstate , "'icmp6' modifier applied to ip6 %s" , typestr );
5377
5382
0 commit comments