Apply the same logc as in gen_host(). Now the unoptimized filter
program for "ip6 dst net ::/0" has no always-true comparisons and is the
same as the optimized one.
case Q_DEFAULT:
case Q_IPV6:
b0 = gen_linktype(cstate, ETHERTYPE_IPV6);
+ // Same as the Q_IP case in gen_host().
+ if (
+ ! memcmp(mask, &in6addr_any, sizeof(struct in6_addr)) &&
+ ! memcmp(addr, &in6addr_any, sizeof(struct in6_addr))
+ )
+ return b0;
b1 = gen_hostop6(cstate, addr, mask, dir, 8, 24);
gen_and(b0, b1);
return b1;
skip => skip_config_undef ('INET6'),
DLT => 'RAW',
aliases => ['ip6 dst net ::/0'],
- opt => '
+ unopt => '
(000) ldb [0]
(001) and #0xf0
(002) jeq #0x60 jt 3 jf 4
(003) ret #262144
(004) ret #0
',
- unopt => '
- (000) ldb [0]
- (001) and #0xf0
- (002) jeq #0x60 jt 3 jf 6
- (003) ld #0x0
- (004) jeq #0x0 jt 5 jf 6
- (005) ret #262144
- (006) ret #0
- ',
}, # ip6_dst_net_0
{
name => 'ip6_dst_net_8',