Skip to content
Permalink
Browse files
nexthop: Add support code for resilient ECMP groups [xxx]
  • Loading branch information
pmachata committed Dec 10, 2020
1 parent 06d8b38 commit dae1ac8af0cc1e9f0b5967822be3aed69a3a7b14
Show file tree
Hide file tree
Showing 3 changed files with 702 additions and 19 deletions.
@@ -855,6 +855,27 @@ static void nsim_fib_dump_inconsistent(struct notifier_block *nb)
data->ipv6.rules.num = 0ULL;
}

static void nsim_nexthop_res_table_dump(u16 grp_id,
struct nh_notifier_res_table_info *info)
{
u32 i;

printk(KERN_WARNING "res_table %d, %d buckets:\n",
grp_id, info->num_nh_buckets);
for (i = 0; i < info->num_nh_buckets; i++)
printk(KERN_WARNING "bucket %d: NH %pI4\n",
i, &info->nhs[i].ipv4);
}

static void nsim_nexthop_res_bucket_dump(u16 grp_id,
struct nh_notifier_res_bucket_info *info)
{
printk(KERN_WARNING "res_table %d, res_bucket %d: NH %pI4 -> %pI4%s\n",
grp_id, info->bucket_index,
&info->old_nh.ipv4, &info->new_nh.ipv4,
info->force ? " (force)" : "");
}

static struct nsim_nexthop *nsim_nexthop_create(struct nsim_fib_data *data,
struct nh_notifier_info *info)
{
@@ -881,6 +902,7 @@ static struct nsim_nexthop *nsim_nexthop_create(struct nsim_fib_data *data,
occ += info->nh_grp->nh_entries[i].weight;
break;
case NH_NOTIFIER_INFO_TYPE_RES_TABLE:
nsim_nexthop_res_table_dump(info->id, info->nh_res_table);
occ = info->nh_res_table->num_nh_buckets;
nexthop->is_resilient = true;
break;
@@ -1036,6 +1058,8 @@ static void nsim_nexthop_remove(struct nsim_fib_data *data,
static int nsim_nexthop_bucket_replace(struct nsim_fib_data *data,
struct nh_notifier_info *info)
{
nsim_nexthop_res_bucket_dump(info->id, info->nh_res_bucket);

if (data->fail_nexthop_bucket_replace) {
NL_SET_ERR_MSG_MOD(info->extack, "Failed to replace nexthop bucket");
return -EINVAL;
@@ -40,6 +40,9 @@ struct nh_config {

struct nlattr *nh_grp;
u16 nh_grp_type;
u32 nh_grp_res_num_buckets;
u32 nh_grp_res_idle_timer;
u32 nh_grp_res_unbalanced_timer;

struct nlattr *nh_encap;
u16 nh_encap_type;
@@ -63,6 +66,30 @@ struct nh_info {
};
};

struct nh_res_bucket {
struct nh_grp_entry *nh_entry;
atomic_long_t used_time;
bool occupied;
u8 nh_flags;
};

struct nh_res_table {
struct net *net;
u32 nhg_id;
struct delayed_work upkeep_dw;

/* List of NHGEs that have too few buckets. Reclaimed buckets will
* be given to entries in this list.
*/
struct list_head uw_nh_entries;

u32 idle_timer;
u32 unbalanced_timer;

u16 num_nh_buckets;
struct nh_res_bucket nh_buckets[];
};

struct nh_grp_entry {
struct nexthop *nh;
u8 weight;
@@ -71,6 +98,15 @@ struct nh_grp_entry {
struct {
atomic_t upper_bound;
} mpath;
struct {
/* Member on uw_nh_entries. */
struct list_head uw_nh_entry;

bool in_reserve;
unsigned long reserve_time;
u16 count_buckets;
u16 wants_buckets;
} res;
};

struct list_head nh_list;
@@ -81,8 +117,11 @@ struct nh_group {
struct nh_group *spare; /* spare group for removals */
u16 num_nh;
bool mpath;
bool resilient;
bool fdb_nh;
bool has_v4;

struct nh_res_table __rcu *res_table;
struct nh_grp_entry nh_entries[];
};

0 comments on commit dae1ac8

Please sign in to comment.