@@ -54,25 +54,30 @@ func (filter *U32) Type() string {
5454
5555type Flower struct {
5656 FilterAttrs
57- DestIP net.IP
58- DestIPMask net.IPMask
59- SrcIP net.IP
60- SrcIPMask net.IPMask
61- EthType uint16
62- EncDestIP net.IP
63- EncDestIPMask net.IPMask
64- EncSrcIP net.IP
65- EncSrcIPMask net.IPMask
66- EncDestPort uint16
67- EncKeyId uint32
68- SrcMac net.HardwareAddr
69- DestMac net.HardwareAddr
70- VlanId uint16
71- SkipHw bool
72- SkipSw bool
73- IPProto * nl.IPProto
74- DestPort uint16
75- SrcPort uint16
57+ ClassId uint32
58+ DestIP net.IP
59+ DestIPMask net.IPMask
60+ SrcIP net.IP
61+ SrcIPMask net.IPMask
62+ EthType uint16
63+ EncDestIP net.IP
64+ EncDestIPMask net.IPMask
65+ EncSrcIP net.IP
66+ EncSrcIPMask net.IPMask
67+ EncDestPort uint16
68+ EncKeyId uint32
69+ SrcMac net.HardwareAddr
70+ DestMac net.HardwareAddr
71+ VlanId uint16
72+ SkipHw bool
73+ SkipSw bool
74+ IPProto * nl.IPProto
75+ DestPort uint16
76+ SrcPort uint16
77+ SrcPortRangeMin uint16
78+ SrcPortRangeMax uint16
79+ DstPortRangeMin uint16
80+ DstPortRangeMax uint16
7681
7782 Actions []Action
7883}
@@ -171,6 +176,19 @@ func (filter *Flower) encode(parent *nl.RtAttr) error {
171176 }
172177 }
173178 }
179+ if filter .SrcPortRangeMin != 0 && filter .SrcPortRangeMax != 0 {
180+ parent .AddRtAttr (nl .TCA_FLOWER_KEY_PORT_SRC_MIN , htons (filter .SrcPortRangeMin ))
181+ parent .AddRtAttr (nl .TCA_FLOWER_KEY_PORT_SRC_MAX , htons (filter .SrcPortRangeMax ))
182+ }
183+
184+ if filter .DstPortRangeMin != 0 && filter .DstPortRangeMax != 0 {
185+ parent .AddRtAttr (nl .TCA_FLOWER_KEY_PORT_DST_MIN , htons (filter .DstPortRangeMin ))
186+ parent .AddRtAttr (nl .TCA_FLOWER_KEY_PORT_DST_MAX , htons (filter .DstPortRangeMax ))
187+ }
188+
189+ if filter .ClassId != 0 {
190+ parent .AddRtAttr (nl .TCA_FLOWER_CLASSID , nl .Uint32Attr (filter .ClassId ))
191+ }
174192
175193 var flags uint32 = 0
176194 if filter .SkipHw {
@@ -247,6 +265,16 @@ func (filter *Flower) decode(data []syscall.NetlinkRouteAttr) error {
247265 if skipHw != 0 {
248266 filter .SkipHw = true
249267 }
268+ case nl .TCA_FLOWER_KEY_PORT_SRC_MIN :
269+ filter .SrcPortRangeMin = ntohs (datum .Value )
270+ case nl .TCA_FLOWER_KEY_PORT_SRC_MAX :
271+ filter .SrcPortRangeMax = ntohs (datum .Value )
272+ case nl .TCA_FLOWER_KEY_PORT_DST_MIN :
273+ filter .DstPortRangeMin = ntohs (datum .Value )
274+ case nl .TCA_FLOWER_KEY_PORT_DST_MAX :
275+ filter .DstPortRangeMax = ntohs (datum .Value )
276+ case nl .TCA_FLOWER_CLASSID :
277+ filter .ClassId = native .Uint32 (datum .Value )
250278 }
251279 }
252280 return nil
0 commit comments