@@ -3,8 +3,9 @@ package openflow13
33import (
44 "encoding/binary"
55
6- "antrea-io/libOpenflow/common"
76 log "github.com/sirupsen/logrus"
7+
8+ "antrea-io/libOpenflow/common"
89)
910
1011// ofp_flow_mod 1.3
@@ -76,7 +77,9 @@ func (f *FlowMod) Len() (n uint16) {
7677
7778func (f * FlowMod ) MarshalBinary () (data []byte , err error ) {
7879 f .Header .Length = f .Len ()
79- data , err = f .Header .MarshalBinary ()
80+ if data , err = f .Header .MarshalBinary (); err != nil {
81+ return
82+ }
8083
8184 bytes := make ([]byte , 40 )
8285 n := 0
@@ -105,11 +108,15 @@ func (f *FlowMod) MarshalBinary() (data []byte, err error) {
105108 n += 2 // for pad
106109 data = append (data , bytes ... )
107110
108- bytes , err = f .Match .MarshalBinary ()
111+ if bytes , err = f .Match .MarshalBinary (); err != nil {
112+ return
113+ }
109114 data = append (data , bytes ... )
110115
111116 for _ , instr := range f .Instructions {
112- bytes , err = instr .MarshalBinary ()
117+ if bytes , err = instr .MarshalBinary (); err != nil {
118+ return
119+ }
113120 data = append (data , bytes ... )
114121 log .Debugf ("flowmod instr: %v" , bytes )
115122 }
@@ -212,9 +219,12 @@ func (f *FlowRemoved) Len() (n uint16) {
212219
213220func (f * FlowRemoved ) MarshalBinary () (data []byte , err error ) {
214221 data = make ([]byte , int (f .Len ()))
222+ var bytes []byte
215223 next := 0
216224
217- bytes , err := f .Header .MarshalBinary ()
225+ if bytes , err = f .Header .MarshalBinary (); err != nil {
226+ return
227+ }
218228 copy (data [next :], bytes )
219229 next += int (f .Header .Len ())
220230
@@ -241,16 +251,19 @@ func (f *FlowRemoved) MarshalBinary() (data []byte, err error) {
241251 binary .BigEndian .PutUint64 (data [next :], f .ByteCount )
242252 next += 8
243253
244- bytes , err = f .Match .MarshalBinary ()
254+ if bytes , err = f .Match .MarshalBinary (); err != nil {
255+ return
256+ }
245257 copy (data [next :], bytes )
246258 next += int (f .Match .Len ())
247259 return
248260}
249261
250262func (f * FlowRemoved ) UnmarshalBinary (data []byte ) error {
251263 next := 0
252- var err error
253- err = f .Header .UnmarshalBinary (data [next :])
264+ if err := f .Header .UnmarshalBinary (data [next :]); err != nil {
265+ return err
266+ }
254267 next += int (f .Header .Len ())
255268
256269 f .Cookie = binary .BigEndian .Uint64 (data [next :])
@@ -274,10 +287,12 @@ func (f *FlowRemoved) UnmarshalBinary(data []byte) error {
274287 f .ByteCount = binary .BigEndian .Uint64 (data [next :])
275288 next += 8
276289
277- err = f .Match .UnmarshalBinary (data [next :])
290+ if err := f .Match .UnmarshalBinary (data [next :]); err != nil {
291+ return err
292+ }
278293 next += int (f .Match .Len ())
279294
280- return err
295+ return nil
281296}
282297
283298// ofp_flow_removed_reason 1.3
0 commit comments