Skip to content

Commit

Permalink
fix: start of SDF will not send measurement (#80)
Browse files Browse the repository at this point in the history
* fix: start of SDF will not send measurement

* drop the first packet for the START reporting trigger

---------

Co-authored-by: roy19991013 <80-ChienAn@users.noreply.gitlab.nems.cs.nctu.edu.tw>
  • Loading branch information
Roy-Hu and roy19991013 committed May 20, 2023
1 parent a483b57 commit 3f42593
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
1 change: 1 addition & 0 deletions include/urr.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "dev.h"
#include "report.h"

#define DONT_SEND_UL_PACKET (-2)
#define SEID_U32ID_HEX_STR_LEN 24
// Measurement Method
#define URR_METHOD_DURAT (1 << 0)
Expand Down
1 change: 1 addition & 0 deletions src/genl/genl_report.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,5 +350,6 @@ void convert_urr_to_report(struct urr *urr, struct usage_report *report)
};

memset(&urr->bytes, 0, sizeof(struct VolumeMeasurement));

urr->start_time = ktime_get_real();
}
10 changes: 8 additions & 2 deletions src/genl/genl_urr.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,14 @@ static int urr_fill(struct urr *urr, struct gtp5g_dev *gtp, struct genl_info *in
if (info->attrs[GTP5G_URR_MEASUREMENT_METHOD])
urr->method = nla_get_u8(info->attrs[GTP5G_URR_MEASUREMENT_METHOD]);

if (info->attrs[GTP5G_URR_REPORTING_TRIGGER])
if (info->attrs[GTP5G_URR_REPORTING_TRIGGER]) {
urr->trigger = nla_get_u32(info->attrs[GTP5G_URR_REPORTING_TRIGGER]);
if (urr->trigger == URR_RPT_TRIGGER_START) {
// Clean bytes to make sure the bytes are counted after the start of service data flow
// TODO: Should send the previous stroed bytes to CP first
memset(&urr->bytes, 0, sizeof(struct VolumeMeasurement));
}
}

if (info->attrs[GTP5G_URR_MEASUREMENT_PERIOD])
urr->period = nla_get_u32(info->attrs[GTP5G_URR_MEASUREMENT_PERIOD]);
Expand All @@ -345,7 +351,7 @@ static int urr_fill(struct urr *urr, struct gtp5g_dev *gtp, struct genl_info *in
parse_volumeqouta(urr, info->attrs[GTP5G_URR_VOLUME_QUOTA]);
urr->consumed = urr->bytes;

if (urr->volumequota.totalVolume == 0) {
if (urr->volumequota.totalVolume == 0 && urr->trigger == URR_RPT_TRIGGER_VOLQU) {
urr_quota_exhaust_action(urr, gtp);
GTP5G_INF(NULL, "URR (%u) Receive zero quota, stop measure", urr->id);
} else if (urr->quota_exhausted) {
Expand Down
22 changes: 18 additions & 4 deletions src/gtpu/encap.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ int check_urr(struct pdr *pdr, struct far *far, u64 vol, u64 vol_mbqe, bool upli
urrs[report_num++] = urr;
urr_quota_exhaust_action(urr, gtp);
GTP5G_TRC(NULL, "URR (%u) Start of Service Data Flow, stop measure until recieve quota", urr->id);
continue;
}

if (urr->info & URR_INFO_MBQE) {
Expand Down Expand Up @@ -645,7 +646,12 @@ int check_urr(struct pdr *pdr, struct far *far, u64 vol, u64 vol_mbqe, bool upli
}

for (i = 0; i < report_num; i++) {
// TODO: FAR ID for Quota Action IE for indicating the action while no quota is granted
if (triggers[i] == USAR_TRIGGER_START){
ret = DONT_SEND_UL_PACKET;
}
convert_urr_to_report(urrs[i], &report[i]);

report[i].trigger = triggers[i];
}

Expand Down Expand Up @@ -767,15 +773,23 @@ static int gtp5g_fwd_skb_encap(struct sk_buff *skb, struct net_device *dev,
uh = udp_hdr(skb);
uh->check = 0;

if (pdr->urr_num != 0) {
ret = check_urr(pdr, far, volume, volume_mbqe, true);
if (ret < 0) {
if (ret == DONT_SEND_UL_PACKET) {
GTP5G_ERR(pdr->dev, "Should not foward the first uplink packet");
return -1;
} else {
GTP5G_ERR(pdr->dev, "Fail to send Usage Report");
}
}
}

if (ip_xmit(skb, pdr->sk, dev) < 0) {
GTP5G_ERR(dev, "Failed to transmit skb through ip_xmit\n");
return -1;
}

if (pdr->urr_num != 0) {
if (check_urr(pdr, far, volume, volume_mbqe, true) < 0)
GTP5G_ERR(pdr->dev, "Fail to send Usage Report");
}
return 0;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/pfcp/urr.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ void urr_update(struct urr *urr, struct gtp5g_dev *gtp)
}
}

// TODO: FAR ID for Quota Action IE for indicating the action while no quota is granted
void urr_quota_exhaust_action(struct urr *urr, struct gtp5g_dev *gtp)
{
struct hlist_head *head;
Expand Down

0 comments on commit 3f42593

Please sign in to comment.