Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Rule struct {
Invert bool
Dport *RulePortRange
Sport *RulePortRange
IPProto int
IPProto int // IPProto is represented as uint8 in the kernel and will be truncated before sending
UIDRange *RuleUIDRange
Protocol uint8
Type uint8
Expand Down
6 changes: 2 additions & 4 deletions rule_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ func ruleHandle(rule *Rule, req *nl.NetlinkRequest) error {
}

if rule.IPProto > 0 {
b := make([]byte, 4)
native.PutUint32(b, uint32(rule.IPProto))
req.AddData(nl.NewRtAttr(nl.FRA_IP_PROTO, b))
req.AddData(nl.NewRtAttr(nl.FRA_IP_PROTO, []byte{byte(rule.IPProto)}))
}

if rule.Dport != nil {
Expand Down Expand Up @@ -282,7 +280,7 @@ func (h *Handle) RuleListFiltered(family int, filter *Rule, filterMask uint64) (
case nl.FRA_PRIORITY:
rule.Priority = int(native.Uint32(attrs[j].Value[0:4]))
case nl.FRA_IP_PROTO:
rule.IPProto = int(native.Uint32(attrs[j].Value[0:4]))
rule.IPProto = int(attrs[j].Value[0])
case nl.FRA_DPORT_RANGE:
rule.Dport = NewRulePortRange(native.Uint16(attrs[j].Value[0:2]), native.Uint16(attrs[j].Value[2:4]))
case nl.FRA_SPORT_RANGE:
Expand Down
Loading