Skip to content

Commit

Permalink
ecmp load-balancing support
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed Jul 15, 2024
1 parent 5993591 commit d34f73f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
7 changes: 5 additions & 2 deletions common/llb_dpapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,12 @@ struct dp_rt_l2nh_act {
__u16 rnh_num;
};

#define DP_MAX_ACTIVE_PATHS (4)

struct dp_rt_nh_act {
__u16 nh_num;
__u16 bd;
__u16 nh_num[DP_MAX_ACTIVE_PATHS];
__u16 naps;
__u16 bd;
__u32 tid;
struct dp_rt_l2nh_act l2nh;
};
Expand Down
2 changes: 1 addition & 1 deletion kernel/llb_kern_l2fwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ dp_do_smac_lkup(void *ctx, struct xfi *xf, void *fc)
static int __always_inline
dp_pipe_set_l22_tun_nh(void *ctx, struct xfi *xf, struct dp_rt_nh_act *rnh)
{
xf->pm.nh_num = rnh->nh_num;
xf->pm.nh_num = rnh->nh_num[0];

/*
* We do not set out_bd here. After NH lookup match is
Expand Down
12 changes: 10 additions & 2 deletions kernel/llb_kern_l3fwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dp_pipe_set_l32_tun_nh(void *ctx, struct xfi *xf,
struct dp_rt_nh_act *rnh)
{
struct dp_rt_l2nh_act *nl2;
xf->pm.nh_num = rnh->nh_num;
xf->pm.nh_num = rnh->nh_num[0];
/*
* We do not set out_bd here. After NH lookup match is
* found and packet tunnel insertion is done, BD is set accordingly
Expand Down Expand Up @@ -120,7 +120,15 @@ dp_do_rtops(void *ctx, struct xfi *xf, void *fa_, struct dp_rt_tact *act)
xf->pm.oport = ra->oport;
} else if (act->ca.act_type == DP_SET_RT_NHNUM) {
struct dp_rt_nh_act *rnh = &act->rt_nh;
xf->pm.nh_num = rnh->nh_num;

if (rnh->naps > 1) {
int sel = dp_get_pkt_hash(ctx) % rnh->naps;
if (sel >= 0 && sel < DP_MAX_ACTIVE_PATHS) {
xf->pm.nh_num = rnh->nh_num[sel];
}
} else {
xf->pm.nh_num = rnh->nh_num[0];
}
return dp_do_rt_fwdops(ctx, xf);
} /*else if (act->ca.act_type == DP_SET_L3RT_TUN_NH) {
#ifdef HAVE_DP_EXTFC
Expand Down

0 comments on commit d34f73f

Please sign in to comment.