示例#1
0
def get_ebpf_manager(config):
    if 'ebpf' not in config or not config['ebpf']['enabled']:
        LOG.info("eBPF manager: Not initilized")
        return None

    gw_info = get_mobilityd_gw_info()
    if not ('nat_iface' in config and 'enodeb_iface' in config):
        LOG.info("eBPF manager: Missing nat_iface/ennodeb_iface")
        return None
    for gw in gw_info:
        if gw.ip.version != IPAddress.IPV4:
            continue
        if gw.vlan in {"NO_VLAN", ""}:
            bpf_man = EbpfManager(config['nat_iface'], config['enodeb_iface'],
                                  gw.ip)
            # TODO: For Development purpose dettch and attach latest eBPF code.
            # Remove this for production deployment
            bpf_man.detach_ul_ebpf()
            bpf_man.detach_dl_ebpf()

            bpf_man.attach_ul_ebpf()
            bpf_man.attach_dl_ebpf()
            LOG.info("eBPF manager: initilized")
            return bpf_man

    return None
示例#2
0
文件: inout.py 项目: talkhasib/magma
    def _monitor_and_update(self):
        while self._gw_mac_monitor_on:
            gw_info_list = get_mobilityd_gw_info()
            for gw_info in gw_info_list:
                if gw_info and gw_info.ip:
                    latest_mac_addr = self._get_gw_mac_address(
                        gw_info.ip, gw_info.vlan)
                    if latest_mac_addr is None or latest_mac_addr == "":
                        latest_mac_addr = gw_info.mac
                    self.logger.debug("mac [%s] for vlan %s", latest_mac_addr,
                                      gw_info.vlan)
                    msgs = self._get_default_egress_flow_msgs(
                        self._datapath,
                        latest_mac_addr,
                        gw_info.vlan,
                        ipv6=(gw_info.ip.version == IPAddress.IPV6),
                    )

                    chan = self._msg_hub.send(msgs, self._datapath)
                    self._wait_for_responses(chan, len(msgs))

                    if latest_mac_addr and latest_mac_addr != "":
                        set_mobilityd_gw_info(
                            gw_info.ip,
                            latest_mac_addr,
                            gw_info.vlan,
                        )
                else:
                    self.logger.warning("No default GW found.")

            hub.sleep(self.config.non_nat_gw_probe_frequency)
示例#3
0
    def _monitor_and_update(self):
        while True:
            gw_info_list = get_mobilityd_gw_info()
            for gw_info in gw_info_list:
                if gw_info and gw_info.ip:
                    latest_mac_addr = self._get_gw_mac_address(gw_info.ip, gw_info.vlan)
                    self.logger.debug("mac [%s] for vlan %s", latest_mac_addr, gw_info.vlan)
                    if latest_mac_addr == "":
                        latest_mac_addr = gw_info.mac

                    self._install_default_egress_flows(self._datapath,
                                                       latest_mac_addr,
                                                       gw_info.vlan)
                    if latest_mac_addr != "":
                        set_mobilityd_gw_info(gw_info.ip,
                                              latest_mac_addr,
                                              gw_info.vlan)
                else:
                    self.logger.warning("No default GW found.")

            hub.sleep(self.config.non_nat_gw_probe_frequency)
示例#4
0
def get_ebpf_manager(config):

    if 'ebpf' in config:
        enabled = config['ebpf']['enabled']
    else:
        enabled = False
    gw_info = get_mobilityd_gw_info()
    for gw in gw_info:
        if gw.vlan == "":
            bpf_man = ebpf_manager(config['nat_iface'], config['enodeb_iface'],
                                   gw.ip, enabled)
            if enabled:
                # TODO: For Development purpose dettch and attach latest eBPF code.
                # Remove this for production deployment
                bpf_man.detach_ul_ebpf()
                bpf_man.attach_ul_ebpf()
                LOG.info("eBPF manager: initilized: enabled: %s", enabled)
            return bpf_man

    LOG.info("eBPF manager: Not initilized")
    return None
示例#5
0
    def _monitor_and_update(self):
        while True:
            updated_info = get_mobilityd_gw_info()
            if updated_info:
                cached_gw_info = updated_info
            if cached_gw_info and cached_gw_info.ip:
                latest_mac_addr = self._get_gw_mac_address(cached_gw_info.ip)
                if len(latest_mac_addr) == 17 and \
                        self._current_upstream_mac != latest_mac_addr:
                    self._install_default_egress_flows(self._datapath,
                                                       latest_mac_addr)
                    cached_gw_info.mac = latest_mac_addr
                    set_gw_info = cached_gw_info
                    set_mobilityd_gw_info(set_gw_info)
                elif latest_mac_addr != "":
                    self.logger.warning("invalid mac: %s", latest_mac_addr)
            else:
                self.logger.warning("No default GW found.")

            self.logger.info("non_mat_gw_probe_frequency: %s mac: [%s]",
                             self.config.non_mat_gw_probe_frequency,
                             self._current_upstream_mac)
            hub.sleep(self.config.non_mat_gw_probe_frequency)