Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
alignchecker: split alignment checks for monitor types into own package
The datapath/alignchecker package also checks the monitor types for proper alignment and thus needs to import the monitor package. These types are not used in the agend but importing the package ends up pulling in github.com/google/gopacket which adds quite a lot to the binary size. Thus, split out the alignment checks for the monitor types into its own subpackage of package monitor, monitor/alignchecker and call the corresponding CheckStructAlignments from tools/alignchecker/main.go as well. This reduces the binary size of cilium-agent by ~2MB. Updates #10056 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
- Loading branch information
Showing
4 changed files
with
60 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2020 Authors of Cilium | ||
// | ||
// 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. | ||
|
||
package alignchecker | ||
|
||
import ( | ||
"reflect" | ||
|
||
check "github.com/cilium/cilium/pkg/alignchecker" | ||
"github.com/cilium/cilium/pkg/monitor" | ||
) | ||
|
||
// See pkg/datapath/alignchecker/alignchecker.go:CheckStructAlignments() | ||
// comment. | ||
func CheckStructAlignments(path string) error { | ||
// Validate alignments of C and Go equivalent structs | ||
toCheck := map[string][]reflect.Type{ | ||
"trace_notify": {reflect.TypeOf(monitor.TraceNotify{})}, | ||
"drop_notify": {reflect.TypeOf(monitor.DropNotify{})}, | ||
"debug_msg": {reflect.TypeOf(monitor.DebugMsg{})}, | ||
"debug_capture_msg": {reflect.TypeOf(monitor.DebugCapture{})}, | ||
} | ||
return check.CheckStructAlignments(path, toCheck) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2020 Authors of Cilium | ||
// | ||
// 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. | ||
|
||
// Package alignchecker is a thin wrapper around pkg/alignchecker to validate | ||
// monitor object alignment. | ||
package alignchecker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters