Skip to content
Open
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
8 changes: 8 additions & 0 deletions cmd/core/display_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ func displayFar(sb *strings.Builder, far *ie.IE) {
if err == nil {
writeLineTabbed(sb, fmt.Sprintf("Header Enrichment: %s : %s ", headerEnrichment.HeaderFieldName, headerEnrichment.HeaderFieldValue), 3)
}
forwardingPolicyIdentifier, err := forwardingParameter.ForwardingPolicyIdentifier()
if err == nil {
writeLineTabbed(sb, fmt.Sprintf("Fordward Policy Identifier: %s ", forwardingPolicyIdentifier), 3)
}
}
}
if updateForwardingParameters, err := far.UpdateForwardingParameters(); err == nil {
Expand All @@ -289,6 +293,10 @@ func displayFar(sb *strings.Builder, far *ie.IE) {
if err == nil {
writeLineTabbed(sb, fmt.Sprintf("Header Enrichment: %s : %s ", headerEnrichment.HeaderFieldName, headerEnrichment.HeaderFieldValue), 3)
}
forwardingPolicyIdentifier, err := updateForwardingParameter.ForwardingPolicyIdentifier()
if err == nil {
writeLineTabbed(sb, fmt.Sprintf("Fordward Policy Identifier: %s ", forwardingPolicyIdentifier), 3)
}
}
}

Expand Down
17 changes: 17 additions & 0 deletions cmd/core/pfcp_session_handlers.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package core

import (
"encoding/base64"
"encoding/binary"
"fmt"
"net"
"strconv"

"github.com/edgecomllc/eupf/cmd/ebpf"

Expand Down Expand Up @@ -480,6 +482,21 @@ func composeFarInfo(far *ie.IE, localIp net.IP, farInfo ebpf.FarInfo) (ebpf.FarI
return ebpf.FarInfo{}, fmt.Errorf("IPv6 not supported yet")
}
}
forwardingPolicyIndex := findIEindex(forward, 41) // IE Type Forwarding Policy
if forwardingPolicyIndex == -1 {
log.Info().Msg("WARN: No ForwardingPolicy")
} else {
forwardingPolicyIdentifier, _ := forward[forwardingPolicyIndex].ForwardingPolicyIdentifier()

forwardingPolicyIdentifierDecode, err := base64.StdEncoding.DecodeString(forwardingPolicyIdentifier)
if err == nil {
uint32Value, err := strconv.ParseUint(string(forwardingPolicyIdentifierDecode), 10, 32)
if err == nil {
farInfo.ForwardingPolicyIdentifier = uint32(uint32Value)
}
}
// TODO support pre-defined policy if forwardingPolicyIdentifier is not base64 treat it as referring to a pre-defined policy
}
}
transportLevelMarking, err := GetTransportLevelMarking(far)
if err == nil {
Expand Down
26 changes: 14 additions & 12 deletions cmd/ebpf/pdr.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,13 @@ func (bpfObjects *BpfObjects) DeleteDownlinkPdrIp6(ipv6 net.IP) error {
}

type FarInfo struct {
Action uint8
OuterHeaderCreation uint8
Teid uint32
RemoteIP uint32
LocalIP uint32
TransportLevelMarking uint16
Action uint8
OuterHeaderCreation uint8
Teid uint32
RemoteIP uint32
LocalIP uint32
TransportLevelMarking uint16
ForwardingPolicyIdentifier uint32
}

func (f FarInfo) MarshalJSON() ([]byte, error) {
Expand All @@ -163,12 +164,13 @@ func (f FarInfo) MarshalJSON() ([]byte, error) {
binary.LittleEndian.PutUint32(remoteIP, f.RemoteIP)
binary.LittleEndian.PutUint32(localIP, f.LocalIP)
data := map[string]interface{}{
"action": f.Action,
"outer_header_creation": f.OuterHeaderCreation,
"teid": f.Teid,
"remote_ip": remoteIP.String(),
"local_ip": localIP.String(),
"transport_level_marking": f.TransportLevelMarking,
"action": f.Action,
"outer_header_creation": f.OuterHeaderCreation,
"teid": f.Teid,
"remote_ip": remoteIP.String(),
"local_ip": localIP.String(),
"transport_level_marking": f.TransportLevelMarking,
"forwarding_policy_identifier": f.ForwardingPolicyIdentifier,
}
return json.Marshal(data)
}
Expand Down
18 changes: 18 additions & 0 deletions cmd/ebpf/xdp/n3n6_entrypoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "xdp/utils/parsers.h"
#include "xdp/utils/csum.h"
#include "xdp/utils/gtp_utils.h"
#include "xdp/utils/nsh_utils.h"
#include "xdp/utils/routing.h"
#include "xdp/utils/icmp.h"

Expand Down Expand Up @@ -313,6 +314,23 @@ static __always_inline enum xdp_action handle_gtp_packet(struct packet_context *
}
}

// Check for forwarding policy identifier
if (far->forwarding_policy_identifier) {
/*
* TODO: support predefined traffic steering policy. Should check
* first if the forwarding policy identifier refers to a pre-defined
* policy, if not we treat this as a SFC ID as below.
*/
// NOTE: The FIB tables need to have been populate prior.
// Traffic with forwarding_policy_identifier should'nt be the first traffic to be received
if (ctx->ip4) {
if (-1 == add_nsh_over_ip4_headers(ctx, far->forwarding_policy_identifier)) {
upf_printk("upf: failed to NSH encapsulate packet");
return XDP_ABORTED;
}
}
}

/*
* Decrement IP TTL and reply TTL exeeded message (debug purspose only)
*/
Expand Down
1 change: 1 addition & 0 deletions cmd/ebpf/xdp/pdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ struct far_info {
__u32 localip;
/* first octet DSCP value in the Type-of-Service, second octet shall contain the ToS/Traffic Class mask field, which shall be set to "0xFC". */
__u16 transport_level_marking;
__u32 forwarding_policy_identifier;
};

/* FAR ID -> FAR */
Expand Down
2 changes: 1 addition & 1 deletion cmd/ebpf/xdp/utils/gtp_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ static __always_inline __u32 add_gtp_over_ip4_headers(struct packet_context *ctx
// udp->check = cs;

/* Update packet pointers */
context_set_ip4(ctx, (char *)(long)ctx->xdp_ctx->data, (const char *)(long)ctx->xdp_ctx->data_end, eth, ip, udp, gtp);
context_set_ip4(ctx, (char *)(long)ctx->xdp_ctx->data, (const char *)(long)ctx->xdp_ctx->data_end, eth, ip, udp, gtp, 0);
return 0;
}

Expand Down
Loading