Skip to content

Commit

Permalink
shortcut-fe:compatible with SQM scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
chongshengB committed Feb 10, 2022
1 parent 0ed4d37 commit d1434f4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
41 changes: 32 additions & 9 deletions trunk/linux-4.4.x/net/shortcut-fe/fast-classifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <linux/spinlock.h>
#include <linux/if_bridge.h>
#include <linux/hashtable.h>
#include <net/pkt_sched.h>
#include <linux/version.h>

#include "sfe_backport.h"
Expand Down Expand Up @@ -244,6 +245,16 @@ int fast_classifier_recv(struct sk_buff *skb)
}
dev = master_dev;
}

#ifdef CONFIG_NET_CLS_ACT
/*
* If ingress Qdisc configured, and packet not processed by ingress Qdisc yet
* We cannot accelerate this packet.
*/
if (dev->ingress_queue && !(skb->tc_verd & TC_NCLS)) {
goto rx_exit;
}
#endif

/*
* We're only interested in IPv4 and IPv6 packets.
Expand Down Expand Up @@ -564,18 +575,14 @@ static void fast_classifier_send_genl_msg(int msg, struct fast_classifier_tuple
#endif
switch (msg) {
case FAST_CLASSIFIER_C_OFFLOADED:
if (rc == 0) {
atomic_inc(&offloaded_msgs);
} else {
atomic_inc(&offloaded_msgs);
if (rc != 0)
atomic_inc(&offloaded_fail_msgs);
}
break;
case FAST_CLASSIFIER_C_DONE:
if (rc == 0) {
atomic_inc(&done_msgs);
} else {
atomic_inc(&done_msgs);
if (rc != 0)
atomic_inc(&done_fail_msgs);
}
break;
default:
DEBUG_ERROR("fast-classifer: Unknown message type sent!\n");
Expand Down Expand Up @@ -825,6 +832,7 @@ static unsigned int fast_classifier_post_routing(struct sk_buff *skb, bool is_v4
struct nf_conntrack_tuple reply_tuple;
struct sfe_connection *conn;
struct sk_buff *tmp_skb = NULL;
SFE_NF_CONN_ACCT(acct);

/*
* Don't process broadcast or multicast packets.
Expand Down Expand Up @@ -891,6 +899,21 @@ static unsigned int fast_classifier_post_routing(struct sk_buff *skb, bool is_v4
DEBUG_TRACE("connection has helper\n");
return NF_ACCEPT;
}

/*
* Check if the acceleration of a flow could be rejected quickly.
*/
acct = nf_conn_acct_find(ct);
if (acct) {
long long packets = atomic64_read(&SFE_ACCT_COUNTER(acct)[CTINFO2DIR(ctinfo)].packets);
if ((packets > 0xff) && (packets & 0xff)) {
/*
* Connection hits slow path at least 256 times, so it must be not able to accelerate.
* But we also give it a chance to walk through ECM every 256 packets
*/
return NF_ACCEPT;
}
}

memset(&sic, 0, sizeof(sic));

Expand Down Expand Up @@ -1647,7 +1670,7 @@ static ssize_t fast_classifier_get_debug_info(struct device *dev,

spin_lock_bh(&sfe_connections_lock);
len += scnprintf(buf, PAGE_SIZE - len, "size=%d offload=%d offload_no_match=%d"
" offloaded=%d done=%d offloaded_fail=%d done_fail=%d\n",
" offloaded=%d done=%d offl_dbg_msg_fail=%d done_dbg_msg_fail=%d\n",
sfe_connections_size,
atomic_read(&offload_msgs),
atomic_read(&offload_no_match_msgs),
Expand Down
11 changes: 11 additions & 0 deletions trunk/linux-4.4.x/net/shortcut-fe/sfe_cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <net/netfilter/nf_conntrack_core.h>
#include <linux/netfilter/xt_dscp.h>
#include <linux/if_bridge.h>
#include <net/pkt_sched.h>
#include <linux/version.h>

#include "sfe.h"
Expand Down Expand Up @@ -133,6 +134,16 @@ int sfe_cm_recv(struct sk_buff *skb)
barrier();

dev = skb->dev;

#ifdef CONFIG_NET_CLS_ACT
/*
* If ingress Qdisc configured, and packet not processed by ingress Qdisc yet
* We cannot accelerate this packet.
*/
if (dev->ingress_queue && !(skb->tc_verd & TC_NCLS)) {
return 0;
}
#endif

/*
* We're only interested in IPv4 and IPv6 packets.
Expand Down

0 comments on commit d1434f4

Please sign in to comment.