-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Cannot parse negated CIDR ex: "!192.168.122.0/24" #70
Comments
stealthybox
added a commit
to stealthybox/ignite
that referenced
this issue
Sep 13, 2019
move fmt.Sprintf out of loop access stat.Options through rawStat[9] with hard-coded index only parse for IPNet when we are working with the proper ignite CNI rules ^ avoids coreos/go-iptables#70
stealthybox
added a commit
to stealthybox/ignite
that referenced
this issue
Sep 13, 2019
move fmt.Sprintf out of loop access stat.Options through rawStat[9] with hard-coded index remove break in the event there are multiple rules per containerID only parse for IPNet when we are working with the proper ignite CNI rules ^ avoids coreos/go-iptables#70
stealthybox
added a commit
to stealthybox/ignite
that referenced
this issue
Sep 13, 2019
move fmt.Sprintf out of loop access stat.Options through rawStat[9] with hard-coded index remove break in the event there are multiple rules per containerID only parse for IPNet when we are working with the proper ignite CNI rules ^ avoids coreos/go-iptables#70
type CustomStat struct {
Packets uint64 `json:"pkts"`
Bytes uint64 `json:"bytes"`
Target string `json:"target"`
Protocol string `json:"prot"`
Opt string `json:"opt"`
Input string `json:"in"`
Output string `json:"out"`
Source string `json:"source"`
Destination string `json:"destination"`
Port string `json:"port"`
Options string `json:"options"`
}
func parseIptablesOutput(output string) ([]CustomStat, error) {
var customStats []CustomStat
scanner := bufio.NewScanner(strings.NewReader(output))
for scanner.Scan() {
line := scanner.Text()
fields := strings.Fields(line)
if len(fields) < 10 {
continue
}
packets, _ := strconv.ParseUint(fields[0], 10, 64)
bytes, _ := strconv.ParseUint(fields[1], 10, 64)
customStats = append(customStats, CustomStat{
Packets: packets,
Bytes: bytes,
Target: fields[2],
Protocol: fields[3],
Opt: fields[4],
Input: fields[5],
Output: fields[6],
Source: fields[7],
Destination: fields[8],
Options: strings.Join(fields[9:], " "),
})
}
return customStats, scanner.Err()
} |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Calling
ipt.StructuredStats("nat", "POSTROUTING")
when rules have negated ranges can error:On my machine, I set up a virtual bridge for this subnet, and these iptables rules were auto-created:
ignite
uses this library call to cleanup chains, and these MASQ rules fail tonet.ParseCIDR
due to the leading exclamation mark negating the subnet: weaveworks/ignite#393Here's a minimal reproduction:
Test Code
Test logs:
The text was updated successfully, but these errors were encountered: