Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multicast address bugfix and improvements #978

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,22 @@ jobs:
runs-on: self-hosted
env:
PKG_CONFIG_PATH: /data/dpdk/dpdklib/lib64/pkgconfig
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
steps:
- uses: actions/checkout@v2
- name: make
- name: Checkout Code
uses: actions/checkout@v3
- name: build
run: make -j

build-all:
runs-on: self-hosted
env:
PKG_CONFIG_PATH: /data/dpdk/dpdklib/lib64/pkgconfig
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
steps:
- uses: actions/checkout@v2
- name: config
- name: Checkout Code
uses: actions/checkout@v3
- name: Config
run: sed -i 's/=n$/=y/' config.mk
- name: make
- name: build
run: make -j
10 changes: 6 additions & 4 deletions .github/workflows/run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ jobs:
runs-on: self-hosted
env:
PKG_CONFIG_PATH: /data/dpdk/dpdklib/lib64/pkgconfig
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
steps:
- uses: actions/checkout@v2
- name: make
- name: Checkout Code
uses: actions/checkout@v3
- name: Build
run: make -j
- name: install
- name: Install
run: make install
- name: run-dpvs
- name: Run DPVS
run: sudo dpvsci $(pwd)/bin/dpvs
13 changes: 13 additions & 0 deletions include/conf/inetaddr.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,17 @@ struct inet_addr_front {
};
#endif /* CONFIG_DPVS_AGENT */

struct inet_maddr_entry {
char ifname[IFNAMSIZ];
union inet_addr maddr;
int af;
uint32_t flags;
uint32_t refcnt;
} __attribute__((__packed__));

struct inet_maddr_array {
int nmaddr;
struct inet_maddr_entry maddrs[0];
} __attribute__((__packed__));

#endif /* __DPVS_INETADDR_CONF_H__ */
37 changes: 37 additions & 0 deletions include/conf/netif_addr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* DPVS is a software load balancer (Virtual Server) based on DPDK.
*
* Copyright (C) 2021 iQIYI (www.iqiyi.com).
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef __DPVS_NETIF_ADDR_CONF_H__
#define __DPVS_NETIF_ADDR_CONF_H__

enum {
HW_ADDR_F_FROM_KNI = 1, // from linux kni device in local layer
};

struct netif_hw_addr_entry {
char addr[18];
uint32_t refcnt;
uint16_t flags;
uint16_t sync_cnt;
} __attribute__((__packed__));

struct netif_hw_addr_array {
int count;
struct netif_hw_addr_entry entries[0];
} __attribute__((__packed__));

#endif
2 changes: 2 additions & 0 deletions include/conf/sockopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
DPVSMSG(SOCKOPT_SET_IFADDR_SET) \
DPVSMSG(SOCKOPT_SET_IFADDR_FLUSH) \
DPVSMSG(SOCKOPT_GET_IFADDR_SHOW) \
DPVSMSG(SOCKOPT_GET_IFMADDR_SHOW) \
\
DPVSMSG(SOCKOPT_NETIF_SET_LCORE) \
DPVSMSG(SOCKOPT_NETIF_SET_PORT) \
Expand All @@ -98,6 +99,7 @@
DPVSMSG(SOCKOPT_NETIF_GET_PORT_XSTATS) \
DPVSMSG(SOCKOPT_NETIF_GET_PORT_EXT_INFO) \
DPVSMSG(SOCKOPT_NETIF_GET_BOND_STATUS) \
DPVSMSG(SOCKOPT_NETIF_GET_MADDR)\
DPVSMSG(SOCKOPT_NETIF_GET_MAX) \
\
DPVSMSG(SOCKOPT_SET_NEIGH_ADD) \
Expand Down
6 changes: 4 additions & 2 deletions include/inetaddr.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ struct inet_device {
struct list_head ifa_list[DPVS_MAX_LCORE]; /* inet_ifaddr list */
struct list_head ifm_list[DPVS_MAX_LCORE]; /* inet_ifmcaddr list*/
uint32_t ifa_cnt[DPVS_MAX_LCORE];
uint32_t ifm_cnt[DPVS_MAX_LCORE];
rte_atomic32_t refcnt; /* not used yet */
#define this_ifa_list ifa_list[rte_lcore_id()]
#define this_ifm_list ifm_list[rte_lcore_id()]
#define this_ifa_cnt ifa_cnt[rte_lcore_id()]
#define this_ifm_cnt ifm_cnt[rte_lcore_id()]
};

/*
Expand All @@ -46,7 +48,7 @@ struct inet_ifmcaddr {
int af;
union inet_addr addr;
uint32_t flags; /* not used yet */
rte_atomic32_t refcnt;
uint32_t refcnt;
};

/*
Expand Down Expand Up @@ -117,7 +119,7 @@ bool inet_chk_mcast_addr(int af, struct netif_port *dev,

void inet_ifaddr_dad_failure(struct inet_ifaddr *ifa);

int idev_add_mcast_init(void *args);
int idev_add_mcast_init(struct netif_port *dev);

int inet_addr_init(void);
int inet_addr_term(void);
Expand Down
28 changes: 1 addition & 27 deletions include/netif.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "list.h"
#include "dpdk.h"
#include "inetaddr.h"
#include "netif_addr.h"
#include "global_data.h"
#include "timer.h"
#include "tc/tc.h"
Expand Down Expand Up @@ -205,31 +206,6 @@ struct netif_ops {
int (*op_get_xstats)(struct netif_port *dev, netif_nic_xstats_get_t **xstats);
};

struct netif_hw_addr {
struct list_head list;
struct rte_ether_addr addr;
rte_atomic32_t refcnt;
/*
* - sync only once!
*
* for HA in upper dev, no matter how many times it's added,
* only sync once to lower (when sync_cnt is zero).
*
* and HA (upper)'s refcnt++, to mark lower dev own's it.
*
* - when to unsync?
*
* when del if HA (upper dev)'s refcnt is 1 and syn_cnt is not zero.
* means lower dev is the only owner and need be unsync.
*/
int sync_cnt;
};

struct netif_hw_addr_list {
struct list_head addrs;
int count;
};

struct netif_port {
char name[IFNAMSIZ]; /* device name */
portid_t id; /* device id */
Expand Down Expand Up @@ -296,8 +272,6 @@ int netif_port_conf_get(struct netif_port *port, struct rte_eth_conf *eth_conf);
int netif_port_conf_set(struct netif_port *port, const struct rte_eth_conf *conf);
int netif_port_start(struct netif_port *port); // start nic and wait until up
int netif_port_stop(struct netif_port *port); // stop nic
int netif_set_mc_list(struct netif_port *port);
int __netif_set_mc_list(struct netif_port *port);
int netif_get_queue(struct netif_port *port, lcoreid_t id, queueid_t *qid);
int netif_get_link(struct netif_port *dev, struct rte_eth_link *link);
int netif_get_promisc(struct netif_port *dev, bool *promisc);
Expand Down
52 changes: 41 additions & 11 deletions include/netif_addr.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,41 @@
*/
#ifndef __DPVS_NETIF_ADDR_H__
#define __DPVS_NETIF_ADDR_H__
#include "netif.h"

int __netif_mc_add(struct netif_port *dev, const struct rte_ether_addr *addr);
int __netif_mc_del(struct netif_port *dev, const struct rte_ether_addr *addr);
#include "conf/netif_addr.h"

struct netif_hw_addr {
struct list_head list;
struct rte_ether_addr addr;
rte_atomic32_t refcnt;
uint16_t flags;
uint16_t sync_cnt;
};

struct netif_hw_addr_list {
struct list_head addrs;
int count;
};

struct netif_port;

int __netif_hw_addr_add(struct netif_hw_addr_list *list,
const struct rte_ether_addr *addr, uint16_t flags);
int __netif_hw_addr_del(struct netif_hw_addr_list *list,
const struct rte_ether_addr *addr, uint16_t flags);

int netif_set_mc_list(struct netif_port *dev);
int __netif_set_mc_list(struct netif_port *dev);

int netif_mc_add(struct netif_port *dev, const struct rte_ether_addr *addr);
int netif_mc_del(struct netif_port *dev, const struct rte_ether_addr *addr);
void netif_mc_flush(struct netif_port *dev);
void netif_mc_init(struct netif_port *dev);
int __netif_mc_dump(struct netif_port *dev,
struct rte_ether_addr *addrs, size_t *naddr);
int netif_mc_dump(struct netif_port *dev,
struct rte_ether_addr *addrs, size_t *naddr);

int __netif_mc_dump(struct netif_port *dev, uint16_t filter_flags,
struct rte_ether_addr *addrs, size_t *naddr);
int netif_mc_dump(struct netif_port *dev, uint16_t filter_flags,
struct rte_ether_addr *addrs, size_t *naddr);
int __netif_mc_print(struct netif_port *dev,
char *buf, int *len, int *pnaddr);
int netif_mc_print(struct netif_port *dev,
Expand All @@ -45,10 +68,12 @@ int netif_mc_sync(struct netif_port *to, struct netif_port *from);
int __netif_mc_unsync(struct netif_port *to, struct netif_port *from);
int netif_mc_unsync(struct netif_port *to, struct netif_port *from);

int __netif_mc_sync_multiple(struct netif_port *to, struct netif_port *from);
int netif_mc_sync_multiple(struct netif_port *to, struct netif_port *from);
int __netif_mc_unsync_multiple(struct netif_port *to, struct netif_port *from);
int netif_mc_unsync_multiple(struct netif_port *to, struct netif_port *from);
int __netif_mc_sync_multiple(struct netif_port *to, struct netif_port *from, int sync_cnt);
int netif_mc_sync_multiple(struct netif_port *to, struct netif_port *from, int sync_cnt);
int __netif_mc_unsync_multiple(struct netif_port *to, struct netif_port *from, int sync_cnt);
int netif_mc_unsync_multiple(struct netif_port *to, struct netif_port *from, int sync_cnt);

int netif_get_multicast_addrs(struct netif_port *dev, void **out, size_t *outlen);

static inline int eth_addr_equal(const struct rte_ether_addr *addr1,
const struct rte_ether_addr *addr2)
Expand All @@ -69,4 +94,9 @@ static inline char *eth_addr_dump(const struct rte_ether_addr *ea,
return buf;
}

static bool inline hw_addr_from_kni(const struct netif_hw_addr *hwa)
{
return !!(hwa->flags & HW_ADDR_F_FROM_KNI);
}

#endif /* __DPVS_NETIF_ADDR_H__ */
Loading
Loading