redirect: Fix handling of local pings
This commit is contained in:
parent
31e29f93cc
commit
51ac6b34f1
2 changed files with 20 additions and 5 deletions
|
|
@ -64,7 +64,7 @@ func (r *autoRedirect) setupNFTables() error {
|
||||||
r.nftablesCreateRedirect(nft, table, chainOutput)
|
r.nftablesCreateRedirect(nft, table, chainOutput)
|
||||||
|
|
||||||
chainOutputUDP := nft.AddChain(&nftables.Chain{
|
chainOutputUDP := nft.AddChain(&nftables.Chain{
|
||||||
Name: "output_udp",
|
Name: "output_udp_icmp",
|
||||||
Table: table,
|
Table: table,
|
||||||
Hooknum: nftables.ChainHookOutput,
|
Hooknum: nftables.ChainHookOutput,
|
||||||
Priority: nftables.ChainPriorityMangle,
|
Priority: nftables.ChainPriorityMangle,
|
||||||
|
|
|
||||||
|
|
@ -439,6 +439,20 @@ func (r *autoRedirect) nftablesCreateExcludeRules(nft *nftables.Conn, table *nft
|
||||||
if r.tunOptions.AutoRedirectMarkMode &&
|
if r.tunOptions.AutoRedirectMarkMode &&
|
||||||
((chain.Hooknum == nftables.ChainHookOutput && chain.Type == nftables.ChainTypeRoute) ||
|
((chain.Hooknum == nftables.ChainHookOutput && chain.Type == nftables.ChainTypeRoute) ||
|
||||||
(chain.Hooknum == nftables.ChainHookPrerouting && chain.Type == nftables.ChainTypeFilter)) {
|
(chain.Hooknum == nftables.ChainHookPrerouting && chain.Type == nftables.ChainTypeFilter)) {
|
||||||
|
ipProto := &nftables.Set{
|
||||||
|
Table: table,
|
||||||
|
Anonymous: true,
|
||||||
|
Constant: true,
|
||||||
|
KeyType: nftables.TypeInetProto,
|
||||||
|
}
|
||||||
|
err := nft.AddSet(ipProto, []nftables.SetElement{
|
||||||
|
{Key: []byte{unix.IPPROTO_UDP}},
|
||||||
|
{Key: []byte{unix.IPPROTO_ICMP}},
|
||||||
|
{Key: []byte{unix.IPPROTO_ICMPV6}},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
nft.AddRule(&nftables.Rule{
|
nft.AddRule(&nftables.Rule{
|
||||||
Table: table,
|
Table: table,
|
||||||
Chain: chain,
|
Chain: chain,
|
||||||
|
|
@ -447,10 +461,11 @@ func (r *autoRedirect) nftablesCreateExcludeRules(nft *nftables.Conn, table *nft
|
||||||
Key: expr.MetaKeyL4PROTO,
|
Key: expr.MetaKeyL4PROTO,
|
||||||
Register: 1,
|
Register: 1,
|
||||||
},
|
},
|
||||||
&expr.Cmp{
|
&expr.Lookup{
|
||||||
Op: expr.CmpOpNeq,
|
SourceRegister: 1,
|
||||||
Register: 1,
|
SetID: ipProto.ID,
|
||||||
Data: []byte{unix.IPPROTO_UDP},
|
SetName: ipProto.Name,
|
||||||
|
Invert: true,
|
||||||
},
|
},
|
||||||
&expr.Verdict{
|
&expr.Verdict{
|
||||||
Kind: expr.VerdictReturn,
|
Kind: expr.VerdictReturn,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue