ede3118cc8
Since #116 implemented fragile comparisons of iptables rules to avoid calling the iptables binary excessively during every reconciliation, the iptables rules for IPIP encapsulation must be updated to match the expected output. One complication is that rather than returning the protocol number in the rule, iptables resolves the protocol number to a name by looking up the number in the netd protocols database. This name can vary depending on the host's environment. This commit adds two solutions for resolving the protocol name: 1. a fixed mapping to the string `ipencap`, which should always work for Kilo whenever it runs in the Alpine Linux container; and 2. a runtime lookup using the netd database, which only works if Kilo is compiled with CGO and is meant to be used only if Kilo is not running in the normal container environment. Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
27 lines
753 B
Go
27 lines
753 B
Go
// Copyright 2021 the Kilo authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
// +build cgo
|
|
|
|
package encapsulation
|
|
|
|
/*
|
|
#include <netdb.h>
|
|
*/
|
|
import "C"
|
|
|
|
func ipipProtocolName() string {
|
|
return C.GoString(C.getprotobynumber(4).p_name)
|
|
}
|