@@ -113,13 +113,13 @@ func (d *driver) checkEncryption(nid string, rIP net.IP, vxlanID uint32, isLocal
113113
114114 if add {
115115 for _ , rIP := range nodes {
116- if err := setupEncryption (lIP , aIP , rIP , vxlanID , d .secMap , d .keys ); err != nil {
116+ if err := d . setupEncryption (lIP , aIP , rIP , vxlanID , d .secMap , d .keys ); err != nil {
117117 logrus .Warnf ("Failed to program network encryption between %s and %s: %v" , lIP , rIP , err )
118118 }
119119 }
120120 } else {
121121 if len (nodes ) == 0 {
122- if err := removeEncryption (lIP , rIP , d .secMap ); err != nil {
122+ if err := d . removeEncryption (lIP , rIP , d .secMap ); err != nil {
123123 logrus .Warnf ("Failed to remove network encryption between %s and %s: %v" , lIP , rIP , err )
124124 }
125125 }
@@ -128,18 +128,18 @@ func (d *driver) checkEncryption(nid string, rIP net.IP, vxlanID uint32, isLocal
128128 return nil
129129}
130130
131- func setupEncryption (localIP , advIP , remoteIP net.IP , vni uint32 , em * encrMap , keys []* key ) error {
131+ func ( d * driver ) setupEncryption (localIP , advIP , remoteIP net.IP , vni uint32 , em * encrMap , keys []* key ) error {
132132 logrus .Debugf ("Programming encryption for vxlan %d between %s and %s" , vni , localIP , remoteIP )
133133 rIPs := remoteIP .String ()
134134
135135 indices := make ([]* spi , 0 , len (keys ))
136136
137- err := programMangle (vni , true )
137+ err := programMangle (vni , d . vxlanPort , true )
138138 if err != nil {
139139 logrus .Warn (err )
140140 }
141141
142- err = programInput (vni , true )
142+ err = programInput (vni , d . vxlanPort , true )
143143 if err != nil {
144144 logrus .Warn (err )
145145 }
@@ -171,7 +171,7 @@ func setupEncryption(localIP, advIP, remoteIP net.IP, vni uint32, em *encrMap, k
171171 return nil
172172}
173173
174- func removeEncryption (localIP , remoteIP net.IP , em * encrMap ) error {
174+ func ( d * driver ) removeEncryption (localIP , remoteIP net.IP , em * encrMap ) error {
175175 em .Lock ()
176176 indices , ok := em .nodes [remoteIP .String ()]
177177 em .Unlock ()
@@ -198,7 +198,7 @@ func removeEncryption(localIP, remoteIP net.IP, em *encrMap) error {
198198 return nil
199199}
200200
201- func programMangle (vni uint32 , add bool ) (err error ) {
201+ func programMangle (vni uint32 , vxlanPort int , add bool ) (err error ) {
202202 var (
203203 p = strconv .FormatUint (uint64 (vxlanPort ), 10 )
204204 c = fmt .Sprintf ("0>>22&0x3C@12&0xFFFFFF00=%d" , int (vni )<< 8 )
@@ -225,7 +225,7 @@ func programMangle(vni uint32, add bool) (err error) {
225225 return
226226}
227227
228- func programInput (vni uint32 , add bool ) (err error ) {
228+ func programInput (vni uint32 , vxlanPort int , add bool ) (err error ) {
229229 var (
230230 port = strconv .FormatUint (uint64 (vxlanPort ), 10 )
231231 vniMatch = fmt .Sprintf ("0>>22&0x3C@12&0xFFFFFF00=%d" , int (vni )<< 8 )
0 commit comments