Skip to content
Merged
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
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
FROM --platform=${TARGETPLATFORM} debian:12-slim AS builder

ARG TARGETARCH
ARG DPDK_VER=23.11
ARG DPDK_VER=23.11.3
ARG DPSERVICE_FEATURES=""

WORKDIR /workspace
Expand Down Expand Up @@ -50,11 +50,13 @@ ENV PATH="${PATH}:/usr/local/go/bin"
ADD http://fast.dpdk.org/rel/dpdk-${DPDK_VER}.tar.xz dpdk.tar.xz
RUN tar -xJf dpdk.tar.xz

ENV DPDK_DIR=/workspace/dpdk-${DPDK_VER}
ENV DPDK_DIR=/workspace/dpdk-stable-${DPDK_VER}

# Copy DPDK patches
COPY hack/*.patch hack/
RUN cd $DPDK_DIR \
&& patch -p1 -R < ../hack/dpdk_23_11_3_mtu.patch \
&& patch -p1 < ../hack/dpdk_23_11_3_fdb_def_rule.patch \
&& patch -p1 < ../hack/dpdk_23_11_log.patch \
&& patch -p1 < ../hack/dpdk_23_11_telemetry_key.patch \
&& patch -p1 < ../hack/dpdk_23_11_ethdev_conversion.patch
Expand Down
13 changes: 13 additions & 0 deletions cli/dp_grpc_client/dp_grpc_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ static char icmp_code_str[30]={0};
static char icmp_type_str[30]={0};
static IpVersion version;
static char get_nat_info_type_str[10]={0};
static char underlay_str[64]={0};

static int command;
static int debug_mode;
Expand Down Expand Up @@ -192,6 +193,7 @@ static uint32_t priority = 1000;
#define CMD_LINE_OPT_VNI_IN_USE "vni_in_use"
#define CMD_LINE_OPT_RESET_VNI "reset_vni"
#define CMD_LINE_OPT_GET_VERSION "getver"
#define CMD_LINE_OPT_UNDERLAY "underlay"

enum {
CMD_LINE_OPT_MIN_NUM = 256,
Expand Down Expand Up @@ -262,6 +264,7 @@ enum {
CMD_LINE_OPT_FWALL_PRIO_NUM,
CMD_LINE_OPT_FWALL_RULE_ID_NUM,
CMD_LINE_OPT_GET_VERSION_NUM,
CMD_LINE_OPT_UNDERLAY_NUM,
};

static const struct option lgopts[] = {
Expand Down Expand Up @@ -335,6 +338,7 @@ static const struct option lgopts[] = {
{CMD_LINE_OPT_FWALL_ICMP_TYP, 1, 0, CMD_LINE_OPT_FWALL_ICMP_TYP_NUM},
{CMD_LINE_OPT_FWALL_RULE_ID, 1, 0, CMD_LINE_OPT_FWALL_RULE_ID_NUM},
{CMD_LINE_OPT_GET_VERSION, 0, 0, CMD_LINE_OPT_GET_VERSION_NUM},
{CMD_LINE_OPT_UNDERLAY, 1, 0, CMD_LINE_OPT_UNDERLAY_NUM},
{NULL, 0, 0, 0},
};

Expand Down Expand Up @@ -614,6 +618,9 @@ static int parse_args(int argc, char **argv)
case CMD_LINE_OPT_GET_VERSION_NUM:
command = DP_CMD_GET_VERSION;
break;
case CMD_LINE_OPT_UNDERLAY_NUM:
strncpy(underlay_str, optarg, 63);
break;
default:
dp_print_usage(prgname);
return -1;
Expand Down Expand Up @@ -650,6 +657,7 @@ class GRPCClient {
request.set_allocated_ipv6_config(ipv6_config);
request.set_allocated_pxe_config(pxe_config);
request.set_interface_type(InterfaceType::VIRTUAL);
request.set_preferred_underlay_route(underlay_str);;
if (vm_pci_str[0] != '\0')
request.set_device_name(vm_pci_str);
CALL_GRPC(CreateInterface, &context, request, &response);
Expand Down Expand Up @@ -1002,6 +1010,7 @@ class GRPCClient {
if(version == IpVersion::IPV4)
vip_ip->set_address(ip_str);
request.set_allocated_vip_ip(vip_ip);
request.set_preferred_underlay_route(underlay_str);
CALL_GRPC(CreateVip, &context, request, &reply);
printf("Received underlay route : %s\n", reply.underlay_route().c_str());
}
Expand All @@ -1022,6 +1031,7 @@ class GRPCClient {
pfx->set_allocated_ip(pfx_ip);
pfx->set_length(length);
request.set_allocated_prefix(pfx);
request.set_preferred_underlay_route(underlay_str);;
CALL_GRPC(CreatePrefix, &context, request, &reply);
printf("Received underlay route : %s\n", reply.underlay_route().c_str());
}
Expand All @@ -1042,6 +1052,7 @@ class GRPCClient {
pfx->set_allocated_ip(pfx_ip);
pfx->set_length(length);
request.set_allocated_prefix(pfx);
request.set_preferred_underlay_route(underlay_str);;
CALL_GRPC(CreateLoadBalancerPrefix, &context, request, &reply);
printf("Received underlay route : %s\n", reply.underlay_route().c_str());
}
Expand All @@ -1067,6 +1078,7 @@ class GRPCClient {
else
lb_ip->set_address(ip6_str);
request.set_allocated_loadbalanced_ip(lb_ip);
request.set_preferred_underlay_route(underlay_str);;

pt = strtok(port_str,",");
while (pt != NULL) {
Expand Down Expand Up @@ -1334,6 +1346,7 @@ class GRPCClient {
request.set_allocated_nat_ip(nat_ip);
request.set_min_port(min_port);
request.set_max_port(max_port);
request.set_preferred_underlay_route(underlay_str);;
CALL_GRPC(CreateNat, &context, request, &reply);
printf("Received underlay route : %s\n", reply.underlay_route().c_str());
}
Expand Down
37 changes: 20 additions & 17 deletions cli/dpservice-cli/cmd/create_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ func CreateInterface(dpdkClientFactory DPDKClientFactory, rendererFactory Render
)

cmd := &cobra.Command{
Use: "interface <--id> [<--ip>] <--vni> <--device> [<--total-meter-rate>] [<--public-meter-rate>]",
Use: "interface <--id> <--ipv4> [<--ipv6>] <--vni> <--device> [<--underlay>] [<--total-meter-rate>] [<--public-meter-rate>]",
Short: "Create an interface",
Example: "dpservice-cli create interface --id=vm4 --ipv4=10.200.1.4 --ipv6=2000:200:1::4 --vni=200 --device=net_tap5 --total-meter-rate=1000(mbits/s) --public-meter-rate=500(mbits/s)",
Example: "dpservice-cli create interface --id=vm4 --ipv4=10.200.1.4 --ipv6=2000:200:1::4 --vni=200 --device=net_tap5 --underlay=fc00::1 --total-meter-rate=1000(mbits/s) --public-meter-rate=500(mbits/s)",
Aliases: InterfaceAliases,
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -45,15 +45,16 @@ func CreateInterface(dpdkClientFactory DPDKClientFactory, rendererFactory Render
}

type CreateInterfaceOptions struct {
ID string
VNI uint32
IPv4 netip.Addr
IPv6 netip.Addr
Device string
PxeServer string
PxeFileName string
TotalMeterRate uint64
PublicMeterRate uint64
ID string
VNI uint32
IPv4 netip.Addr
IPv6 netip.Addr
Device string
PreferredUnderlay netip.Addr
PxeServer string
PxeFileName string
TotalMeterRate uint64
PublicMeterRate uint64
}

func (o *CreateInterfaceOptions) AddFlags(fs *pflag.FlagSet) {
Expand All @@ -62,6 +63,7 @@ func (o *CreateInterfaceOptions) AddFlags(fs *pflag.FlagSet) {
flag.AddrVar(fs, &o.IPv4, "ipv4", o.IPv4, "IPv4 address to assign to the interface.")
flag.AddrVar(fs, &o.IPv6, "ipv6", netip.IPv6Unspecified(), "IPv6 address to assign to the interface.")
fs.StringVar(&o.Device, "device", o.Device, "Device to allocate.")
flag.AddrVar(fs, &o.PreferredUnderlay, "underlay", netip.IPv6Unspecified(), "IPv6 underlay address use for the interface.")
fs.StringVar(&o.PxeServer, "pxe-server", o.PxeServer, "PXE next server.")
fs.StringVar(&o.PxeFileName, "pxe-file-name", o.PxeFileName, "PXE boot file name.")
fs.Uint64Var(&o.TotalMeterRate, "total-meter-rate", 0, "Total meter rate.")
Expand Down Expand Up @@ -89,12 +91,13 @@ func RunCreateInterface(ctx context.Context, dpdkClientFactory DPDKClientFactory
ID: opts.ID,
},
Spec: api.InterfaceSpec{
VNI: opts.VNI,
Device: opts.Device,
IPv4: &opts.IPv4,
IPv6: &opts.IPv6,
PXE: &api.PXE{Server: opts.PxeServer, FileName: opts.PxeFileName},
Metering: &api.MeteringParams{TotalRate: opts.TotalMeterRate, PublicRate: opts.PublicMeterRate},
VNI: opts.VNI,
Device: opts.Device,
IPv4: &opts.IPv4,
IPv6: &opts.IPv6,
UnderlayRoute: &opts.PreferredUnderlay,
PXE: &api.PXE{Server: opts.PxeServer, FileName: opts.PxeFileName},
Metering: &api.MeteringParams{TotalRate: opts.TotalMeterRate, PublicRate: opts.PublicMeterRate},
},
})
if err != nil {
Expand Down
21 changes: 12 additions & 9 deletions cli/dpservice-cli/cmd/create_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ func CreateLoadBalancer(dpdkClientFactory DPDKClientFactory, rendererFactory Ren
)

cmd := &cobra.Command{
Use: "loadbalancer <--id> <--vni> <--vip> <--lbports>",
Use: "loadbalancer <--id> <--vni> <--vip> <--lbports> [<--underlay>]",
Short: "Create a loadbalancer",
Example: "dpservice-cli create loadbalancer --id=4 --vni=100 --vip=10.20.30.40 --lbports=TCP/443,UDP/53",
Example: "dpservice-cli create loadbalancer --id=4 --vni=100 --vip=10.20.30.40 --lbports=TCP/443,UDP/53 --underlay=fc00::4",
Aliases: LoadBalancerAliases,
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -45,17 +45,19 @@ func CreateLoadBalancer(dpdkClientFactory DPDKClientFactory, rendererFactory Ren
}

type CreateLoadBalancerOptions struct {
Id string
VNI uint32
LbVipIP netip.Addr
Lbports []string
Id string
VNI uint32
LbVipIP netip.Addr
Lbports []string
PreferredUnderlay netip.Addr
}

func (o *CreateLoadBalancerOptions) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&o.Id, "id", o.Id, "Loadbalancer ID to add.")
fs.Uint32Var(&o.VNI, "vni", o.VNI, "VNI to add the loadbalancer to.")
flag.AddrVar(fs, &o.LbVipIP, "vip", o.LbVipIP, "VIP to assign to the loadbalancer.")
fs.StringSliceVar(&o.Lbports, "lbports", o.Lbports, "LB ports to assign to the loadbalancer.")
flag.AddrVar(fs, &o.PreferredUnderlay, "underlay", netip.IPv6Unspecified(), "IPv6 underlay address use for the loadbalancer.")
}

func (o *CreateLoadBalancerOptions) MarkRequiredFlags(cmd *cobra.Command) error {
Expand Down Expand Up @@ -88,9 +90,10 @@ func RunCreateLoadBalancer(ctx context.Context, dpdkClientFactory DPDKClientFact
ID: opts.Id,
},
Spec: api.LoadBalancerSpec{
VNI: opts.VNI,
LbVipIP: &opts.LbVipIP,
Lbports: ports,
VNI: opts.VNI,
LbVipIP: &opts.LbVipIP,
Lbports: ports,
UnderlayRoute: &opts.PreferredUnderlay,
},
})
if err != nil {
Expand Down
13 changes: 8 additions & 5 deletions cli/dpservice-cli/cmd/create_loadbalancer_prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ func CreateLoadBalancerPrefix(
)

cmd := &cobra.Command{
Use: "lbprefix <--prefix> <--interface-id>",
Use: "lbprefix <--prefix> <--interface-id> [<--underlay>]",
Short: "Create a loadbalancer prefix",
Example: "dpservice-cli create lbprefix --prefix=10.10.10.0/24 --interface-id=vm1",
Example: "dpservice-cli create lbprefix --prefix=10.10.10.0/24 --interface-id=vm1 --underlay=fc00::2",
Args: cobra.ExactArgs(0),
Aliases: LoadBalancerPrefixAliases,
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -49,13 +49,15 @@ func CreateLoadBalancerPrefix(
}

type CreateLoadBalancerPrefixOptions struct {
Prefix netip.Prefix
InterfaceID string
Prefix netip.Prefix
InterfaceID string
PreferredUnderlay netip.Addr
}

func (o *CreateLoadBalancerPrefixOptions) AddFlags(fs *pflag.FlagSet) {
flag.PrefixVar(fs, &o.Prefix, "prefix", o.Prefix, "Prefix to add to the interface.")
fs.StringVar(&o.InterfaceID, "interface-id", o.InterfaceID, "ID of the interface to create the prefix for.")
flag.AddrVar(fs, &o.PreferredUnderlay, "underlay", netip.IPv6Unspecified(), "IPv6 underlay address use for the prefix.")
}

func (o *CreateLoadBalancerPrefixOptions) MarkRequiredFlags(cmd *cobra.Command) error {
Expand Down Expand Up @@ -84,7 +86,8 @@ func RunCreateLoadBalancerPrefix(
InterfaceID: opts.InterfaceID,
},
Spec: api.LoadBalancerPrefixSpec{
Prefix: opts.Prefix,
Prefix: opts.Prefix,
UnderlayRoute: &opts.PreferredUnderlay,
},
})
if err != nil {
Expand Down
21 changes: 12 additions & 9 deletions cli/dpservice-cli/cmd/create_nat.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ func CreateNat(dpdkClientFactory DPDKClientFactory, rendererFactory RendererFact
)

cmd := &cobra.Command{
Use: "nat <--interface-id> <--nat-ip> <--minport> <--maxport>",
Use: "nat <--interface-id> <--nat-ip> <--minport> <--maxport> [<--underlay>]",
Short: "Create a NAT on interface",
Example: "dpservice-cli create nat --interface-id=vm1 --nat-ip=10.20.30.40 --minport=30000 --maxport=30100",
Example: "dpservice-cli create nat --interface-id=vm1 --nat-ip=10.20.30.40 --minport=30000 --maxport=30100 --underlay=fc00::5",
Aliases: NatAliases,
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -46,17 +46,19 @@ func CreateNat(dpdkClientFactory DPDKClientFactory, rendererFactory RendererFact
}

type CreateNatOptions struct {
InterfaceID string
NatIP netip.Addr
MinPort uint32
MaxPort uint32
InterfaceID string
NatIP netip.Addr
MinPort uint32
MaxPort uint32
PreferredUnderlay netip.Addr
}

func (o *CreateNatOptions) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&o.InterfaceID, "interface-id", o.InterfaceID, "Interface ID where to create NAT.")
fs.Uint32Var(&o.MinPort, "minport", o.MinPort, "MinPort of NAT.")
fs.Uint32Var(&o.MaxPort, "maxport", o.MaxPort, "MaxPort of NAT.")
flag.AddrVar(fs, &o.NatIP, "nat-ip", o.NatIP, "NAT IP to assign to the interface.")
flag.AddrVar(fs, &o.PreferredUnderlay, "underlay", netip.IPv6Unspecified(), "IPv6 underlay address use for the NAT.")
}

func (o *CreateNatOptions) MarkRequiredFlags(cmd *cobra.Command) error {
Expand All @@ -80,9 +82,10 @@ func RunCreateNat(ctx context.Context, dpdkClientFactory DPDKClientFactory, rend
InterfaceID: opts.InterfaceID,
},
Spec: api.NatSpec{
NatIP: &opts.NatIP,
MinPort: opts.MinPort,
MaxPort: opts.MaxPort,
NatIP: &opts.NatIP,
MinPort: opts.MinPort,
MaxPort: opts.MaxPort,
UnderlayRoute: &opts.PreferredUnderlay,
},
})
if err != nil {
Expand Down
13 changes: 8 additions & 5 deletions cli/dpservice-cli/cmd/create_prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ func CreatePrefix(
)

cmd := &cobra.Command{
Use: "prefix <--prefix> <--interface-id>",
Use: "prefix <--prefix> <--interface-id> [<--underlay>]",
Short: "Create a prefix on interface.",
Example: "dpservice-cli create prefix --prefix=10.20.30.0/24 --interface-id=vm1",
Example: "dpservice-cli create prefix --prefix=10.20.30.0/24 --interface-id=vm1 --underlay=fc00::3",
Args: cobra.ExactArgs(0),
Aliases: PrefixAliases,
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -49,13 +49,15 @@ func CreatePrefix(
}

type CreatePrefixOptions struct {
Prefix netip.Prefix
InterfaceID string
Prefix netip.Prefix
InterfaceID string
PreferredUnderlay netip.Addr
}

func (o *CreatePrefixOptions) AddFlags(fs *pflag.FlagSet) {
flag.PrefixVar(fs, &o.Prefix, "prefix", o.Prefix, "Prefix to create on the interface.")
fs.StringVar(&o.InterfaceID, "interface-id", o.InterfaceID, "ID of the interface where to create the prefix.")
flag.AddrVar(fs, &o.PreferredUnderlay, "underlay", netip.IPv6Unspecified(), "IPv6 underlay address use for the prefix.")
}

func (o *CreatePrefixOptions) MarkRequiredFlags(cmd *cobra.Command) error {
Expand Down Expand Up @@ -84,7 +86,8 @@ func RunCreatePrefix(
InterfaceID: opts.InterfaceID,
},
Spec: api.PrefixSpec{
Prefix: opts.Prefix,
Prefix: opts.Prefix,
UnderlayRoute: &opts.PreferredUnderlay,
},
})
if err != nil {
Expand Down
13 changes: 8 additions & 5 deletions cli/dpservice-cli/cmd/create_virtualip.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ func CreateVirtualIP(dpdkClientFactory DPDKClientFactory, rendererFactory Render
)

cmd := &cobra.Command{
Use: "virtualip <--vip> <--interface-id>",
Use: "virtualip <--vip> <--interface-id> [<--underlay>]",
Short: "Create a virtual IP on interface.",
Example: "dpservice-cli create virtualip --vip=20.20.20.20 --interface-id=vm1",
Example: "dpservice-cli create virtualip --vip=20.20.20.20 --interface-id=vm1 --underlay=fc00::6",
Aliases: VirtualIPAliases,
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -46,13 +46,15 @@ func CreateVirtualIP(dpdkClientFactory DPDKClientFactory, rendererFactory Render
}

type CreateVirtualIPOptions struct {
Vip netip.Addr
InterfaceID string
Vip netip.Addr
InterfaceID string
PreferredUnderlay netip.Addr
}

func (o *CreateVirtualIPOptions) AddFlags(fs *pflag.FlagSet) {
flag.AddrVar(fs, &o.Vip, "vip", o.Vip, "Virtual IP to create on interface.")
fs.StringVar(&o.InterfaceID, "interface-id", o.InterfaceID, "Interface ID where to create the virtual IP.")
flag.AddrVar(fs, &o.PreferredUnderlay, "underlay", netip.IPv6Unspecified(), "IPv6 underlay address use for the VIP.")
}

func (o *CreateVirtualIPOptions) MarkRequiredFlags(cmd *cobra.Command) error {
Expand Down Expand Up @@ -81,7 +83,8 @@ func RunCreateVirtualIP(
InterfaceID: opts.InterfaceID,
},
Spec: api.VirtualIPSpec{
IP: &opts.Vip,
IP: &opts.Vip,
UnderlayRoute: &opts.PreferredUnderlay,
},
})
if err != nil {
Expand Down
Loading
Loading