@@ -3,11 +3,11 @@ package overlay
33import (
44 "fmt"
55 "net"
6- "strings"
76
87 log "github.com/Sirupsen/logrus"
98 "github.com/docker/libnetwork/driverapi"
109 "github.com/docker/libnetwork/types"
10+ "github.com/gogo/protobuf/proto"
1111 "github.com/vishvananda/netlink"
1212)
1313
@@ -106,7 +106,16 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
106106 d .peerDbAdd (nid , eid , ep .addr .IP , ep .addr .Mask , ep .mac ,
107107 net .ParseIP (d .bindAddress ), true )
108108
109- if err := jinfo .AddTableEntry (ovPeerTable , eid , []byte (fmt .Sprintf ("%s,%s,%s" , ep .addr , ep .mac , d .bindAddress ))); err != nil {
109+ buf , err := proto .Marshal (& PeerRecord {
110+ EndpointIP : ep .addr .String (),
111+ EndpointMAC : ep .mac .String (),
112+ TunnelEndpointIP : d .bindAddress ,
113+ })
114+ if err != nil {
115+ return err
116+ }
117+
118+ if err := jinfo .AddTableEntry (ovPeerTable , eid , buf ); err != nil {
110119 log .Errorf ("overlay: Failed adding table entry to joininfo: %v" , err )
111120 }
112121
@@ -122,27 +131,28 @@ func (d *driver) EventNotify(etype driverapi.EventType, nid, tableName, key stri
122131 }
123132
124133 eid := key
125- values := strings .Split (string (value ), "," )
126- if len (values ) < 3 {
127- log .Errorf ("Invalid value %s received through event notify" , string (value ))
134+
135+ var peer PeerRecord
136+ if err := proto .Unmarshal (value , & peer ); err != nil {
137+ log .Errorf ("Failed to unmarshal peer record: %v" , err )
128138 return
129139 }
130140
131- addr , err := types .ParseCIDR (values [ 0 ] )
141+ addr , err := types .ParseCIDR (peer . EndpointIP )
132142 if err != nil {
133- log .Errorf ("Invalid peer IP %s received in event notify" , values [ 0 ] )
143+ log .Errorf ("Invalid peer IP %s received in event notify" , peer . EndpointIP )
134144 return
135145 }
136146
137- mac , err := net .ParseMAC (values [ 1 ] )
147+ mac , err := net .ParseMAC (peer . EndpointMAC )
138148 if err != nil {
139- log .Errorf ("Invalid mac %s received in event notify" , values [ 1 ] )
149+ log .Errorf ("Invalid mac %s received in event notify" , peer . EndpointMAC )
140150 return
141151 }
142152
143- vtep := net .ParseIP (values [ 2 ] )
153+ vtep := net .ParseIP (peer . TunnelEndpointIP )
144154 if vtep == nil {
145- log .Errorf ("Invalid VTEP %s received in event notify" , values [ 2 ] )
155+ log .Errorf ("Invalid VTEP %s received in event notify" , peer . TunnelEndpointIP )
146156 return
147157 }
148158
0 commit comments