@@ -62,6 +62,25 @@ func (nfqueue *Nfqueue) SetVerdictWithConnMark(id uint32, verdict, mark int) err
6262 return nfqueue .setVerdict (id , verdict , false , attributes )
6363}
6464
65+ // SetVerdictWithLabel signals the kernel the next action and the label for a specified package id
66+ func (nfqueue * Nfqueue ) SetVerdictWithLabel (id uint32 , verdict int , label []byte ) error {
67+ ctAttrs , err := netlink .MarshalAttributes ([]netlink.Attribute {{
68+ Type : ctaLabels ,
69+ Data : label ,
70+ }})
71+ if err != nil {
72+ return err
73+ }
74+ attributes , err := netlink .MarshalAttributes ([]netlink.Attribute {{
75+ Type : netlink .Nested | nfQaCt ,
76+ Data : ctAttrs ,
77+ }})
78+ if err != nil {
79+ return err
80+ }
81+ return nfqueue .setVerdict (id , verdict , false , attributes )
82+ }
83+
6584// SetVerdictModPacket signals the kernel the next action for an altered packet
6685func (nfqueue * Nfqueue ) SetVerdictModPacket (id uint32 , verdict int , packet []byte ) error {
6786 data , err := netlink .MarshalAttributes ([]netlink.Attribute {{
@@ -121,6 +140,31 @@ func (nfqueue *Nfqueue) SetVerdictModPacketWithConnMark(id uint32, verdict, mark
121140 return nfqueue .setVerdict (id , verdict , false , data )
122141}
123142
143+ // SetVerdictModPacketWithLabel signals the kernel the next action and label for an altered packet
144+ func (nfqueue * Nfqueue ) SetVerdictModPacketWithLabel (id uint32 , verdict int , label []byte , packet []byte ) error {
145+ ctAttrs , err := netlink .MarshalAttributes ([]netlink.Attribute {{
146+ Type : ctaLabels ,
147+ Data : label ,
148+ }})
149+ if err != nil {
150+ return err
151+ }
152+ data , err := netlink .MarshalAttributes ([]netlink.Attribute {
153+ {
154+ Type : nfQaPayload ,
155+ Data : packet ,
156+ },
157+ {
158+ Type : netlink .Nested | nfQaCt ,
159+ Data : ctAttrs ,
160+ },
161+ })
162+ if err != nil {
163+ return err
164+ }
165+ return nfqueue .setVerdict (id , verdict , false , data )
166+ }
167+
124168// SetVerdict signals the kernel the next action for a specified package id
125169func (nfqueue * Nfqueue ) SetVerdict (id uint32 , verdict int ) error {
126170 return nfqueue .setVerdict (id , verdict , false , []byte {})
0 commit comments