def load_ifinfmsg(schema, target, event): # # link goes down: flush all related routes # if not event['flags'] & 1: schema.execute( 'DELETE FROM routes WHERE ' 'f_target = %s AND ' 'f_RTA_OIF = %s OR f_RTA_IIF = %s' % (schema.plch, schema.plch, schema.plch), (target, event['index'], event['index'])) # # ignore wireless updates # if event.get_attr('IFLA_WIRELESS'): return # # AF_BRIDGE events # if event['family'] == AF_BRIDGE: # # bypass for now # return schema.load_netlink('interfaces', target, event) # # load ifinfo, if exists # if not event['header'].get('type', 0) % 2: linkinfo = event.get_attr('IFLA_LINKINFO') if linkinfo is not None: iftype = linkinfo.get_attr('IFLA_INFO_KIND') table = 'ifinfo_%s' % iftype if iftype == 'gre': ifdata = linkinfo.get_attr('IFLA_INFO_DATA') local = ifdata.get_attr('IFLA_GRE_LOCAL') remote = ifdata.get_attr('IFLA_GRE_REMOTE') p2p = p2pmsg() p2p['index'] = event['index'] p2p['family'] = 2 p2p['attrs'] = [('P2P_LOCAL', local), ('P2P_REMOTE', remote)] schema.load_netlink('p2p', target, p2p) elif iftype == 'veth': link = event.get_attr('IFLA_LINK') # for veth interfaces, IFLA_LINK points to # the peer -- but NOT in automatic updates if (not link) and \ (target in schema.ndb.sources.keys()): schema.log.debug('reload veth %s' % event['index']) update = (schema.ndb.sources[target].api( 'link', 'get', index=event['index'])) update = tuple(update)[0] return schema.load_netlink('interfaces', target, update) if table in schema.spec: ifdata = linkinfo.get_attr('IFLA_INFO_DATA') ifdata['header'] = {} ifdata['index'] = event['index'] schema.load_netlink(table, target, ifdata)
def load_ifinfmsg(self, target, event): # # link goes down: flush all related routes # if not event['flags'] & 1: self.execute( 'DELETE FROM routes WHERE ' 'f_target = %s AND ' 'f_RTA_OIF = %s OR f_RTA_IIF = %s' % (self.plch, self.plch, self.plch), (target, event['index'], event['index'])) # # ignore wireless updates # if event.get_attr('IFLA_WIRELESS'): return # # AF_BRIDGE events # if event['family'] == AF_BRIDGE: # # bypass for now # return self.load_netlink('interfaces', target, event) # # load ifinfo, if exists # if not event['header'].get('type', 0) % 2: linkinfo = event.get_attr('IFLA_LINKINFO') if linkinfo is not None: iftype = linkinfo.get_attr('IFLA_INFO_KIND') table = 'ifinfo_%s' % iftype if iftype == 'gre': ifdata = linkinfo.get_attr('IFLA_INFO_DATA') local = ifdata.get_attr('IFLA_GRE_LOCAL') remote = ifdata.get_attr('IFLA_GRE_REMOTE') p2p = p2pmsg() p2p['index'] = event['index'] p2p['family'] = 2 p2p['attrs'] = [('P2P_LOCAL', local), ('P2P_REMOTE', remote)] self.load_netlink('p2p', target, p2p) if table in self.spec: ifdata = linkinfo.get_attr('IFLA_INFO_DATA') ifdata['header'] = {} ifdata['index'] = event['index'] self.load_netlink(table, target, ifdata)
def load_ifinfmsg(self, target, event): # # link goes down: flush all related routes # if not event['flags'] & 1: self.execute('DELETE FROM routes WHERE ' 'f_target = %s AND ' 'f_RTA_OIF = %s OR f_RTA_IIF = %s' % (self.plch, self.plch, self.plch), (target, event['index'], event['index'])) # # ignore wireless updates # if event.get_attr('IFLA_WIRELESS'): return # # AF_BRIDGE events # if event['family'] == AF_BRIDGE: # # bypass for now # return self.load_netlink('interfaces', target, event) # # load ifinfo, if exists # if not event['header'].get('type', 0) % 2: linkinfo = event.get_attr('IFLA_LINKINFO') if linkinfo is not None: iftype = linkinfo.get_attr('IFLA_INFO_KIND') table = 'ifinfo_%s' % iftype if iftype == 'gre': ifdata = linkinfo.get_attr('IFLA_INFO_DATA') local = ifdata.get_attr('IFLA_GRE_LOCAL') remote = ifdata.get_attr('IFLA_GRE_REMOTE') p2p = p2pmsg() p2p['index'] = event['index'] p2p['family'] = 2 p2p['attrs'] = [('P2P_LOCAL', local), ('P2P_REMOTE', remote)] self.load_netlink('p2p', target, p2p) if table in self.spec: ifdata = linkinfo.get_attr('IFLA_INFO_DATA') ifdata['header'] = {} ifdata['index'] = event['index'] self.load_netlink(table, target, ifdata)
def load_ifinfmsg(schema, target, event): # # link goes down: flush all related routes # if not event['flags'] & 1: schema.execute('DELETE FROM routes WHERE ' 'f_target = %s AND ' 'f_RTA_OIF = %s OR f_RTA_IIF = %s' % (schema.plch, schema.plch, schema.plch), (target, event['index'], event['index'])) # # ignore wireless updates # if event.get_attr('IFLA_WIRELESS'): return # # AF_BRIDGE events # if event['family'] == AF_BRIDGE: # schema.load_netlink('af_bridge_ifs', target, event) try: vlans = (event .get_attr('IFLA_AF_SPEC') .get_attrs('IFLA_BRIDGE_VLAN_INFO')) except AttributeError: # AttributeError: 'NoneType' object has no attribute 'get_attrs' # -- vlan filters not supported return # flush the old vlans info schema.execute(''' DELETE FROM af_bridge_vlans WHERE f_target = %s AND f_index = %s ''' % (schema.plch, schema.plch), (target, event['index'])) for v in vlans: v['index'] = event['index'] v['header'] = {'type': event['header']['type']} schema.load_netlink('af_bridge_vlans', target, v) return schema.load_netlink('interfaces', target, event) # # load ifinfo, if exists # if not event['header'].get('type', 0) % 2: linkinfo = event.get_attr('IFLA_LINKINFO') if linkinfo is not None: iftype = linkinfo.get_attr('IFLA_INFO_KIND') table = 'ifinfo_%s' % iftype if iftype == 'gre': ifdata = linkinfo.get_attr('IFLA_INFO_DATA') local = ifdata.get_attr('IFLA_GRE_LOCAL') remote = ifdata.get_attr('IFLA_GRE_REMOTE') p2p = p2pmsg() p2p['index'] = event['index'] p2p['family'] = 2 p2p['attrs'] = [('P2P_LOCAL', local), ('P2P_REMOTE', remote)] schema.load_netlink('p2p', target, p2p) elif iftype == 'veth': link = event.get_attr('IFLA_LINK') # for veth interfaces, IFLA_LINK points to # the peer -- but NOT in automatic updates if (not link) and \ (target in schema.ndb.sources.keys()): schema.log.debug('reload veth %s' % event['index']) update = (schema .ndb .sources[target] .api('link', 'get', index=event['index'])) update = tuple(update)[0] return schema.load_netlink('interfaces', target, update) if table in schema.spec: ifdata = linkinfo.get_attr('IFLA_INFO_DATA') ifdata['header'] = {} ifdata['index'] = event['index'] schema.load_netlink(table, target, ifdata)
def load_ifinfmsg(self, target, event): # # link goes down: flush all related routes # if not event['flags'] & 1: self.execute('DELETE FROM routes WHERE ' 'f_target = %s AND ' 'f_RTA_OIF = %s OR f_RTA_IIF = %s' % (self.plch, self.plch, self.plch), (target, event['index'], event['index'])) # # ignore wireless updates # if event.get_attr('IFLA_WIRELESS'): return # # AF_BRIDGE events # if event['family'] == AF_BRIDGE: # # bypass for now # return self.load_netlink('interfaces', target, event) # # load ifinfo, if exists # if not event['header'].get('type', 0) % 2: linkinfo = event.get_attr('IFLA_LINKINFO') if linkinfo is not None: iftype = linkinfo.get_attr('IFLA_INFO_KIND') table = 'ifinfo_%s' % iftype if iftype == 'gre': ifdata = linkinfo.get_attr('IFLA_INFO_DATA') local = ifdata.get_attr('IFLA_GRE_LOCAL') remote = ifdata.get_attr('IFLA_GRE_REMOTE') p2p = p2pmsg() p2p['index'] = event['index'] p2p['family'] = 2 p2p['attrs'] = [('P2P_LOCAL', local), ('P2P_REMOTE', remote)] self.load_netlink('p2p', target, p2p) elif iftype == 'veth': link = event.get_attr('IFLA_LINK') # for veth interfaces, IFLA_LINK points to # the peer -- but NOT in automatic updates if (not link) and \ (target in self.ndb.sources.keys()): self.log.debug('reload veth %s' % event['index']) update = (self .ndb .sources[target] .api('link', 'get', index=event['index'])) update = tuple(update)[0] return self.load_netlink('interfaces', target, update) if table in self.spec: ifdata = linkinfo.get_attr('IFLA_INFO_DATA') ifdata['header'] = {} ifdata['index'] = event['index'] self.load_netlink(table, target, ifdata)