|
| 1 | +diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c |
| 2 | +index fffa011a007d..0acb98749f19 100644 |
| 3 | +--- a/net/ipv4/tcp_cubic.c |
| 4 | ++++ b/net/ipv4/tcp_cubic.c |
| 5 | +@@ -29,11 +29,24 @@ |
| 6 | + #include <linux/math64.h> |
| 7 | + #include <net/tcp.h> |
| 8 | + |
| 9 | ++#include <linux/fs.h> |
| 10 | ++#include <asm/segment.h> |
| 11 | ++#include <asm/uaccess.h> |
| 12 | ++#include <linux/buffer_head.h> |
| 13 | ++#include <linux/kthread.h> |
| 14 | ++#include <linux/irqflags.h> |
| 15 | ++#include <linux/kernel.h> |
| 16 | ++#include <linux/netlink.h> |
| 17 | ++#include <net/netlink.h> |
| 18 | ++#include <net/net_namespace.h> |
| 19 | ++ |
| 20 | + #define BICTCP_BETA_SCALE 1024 /* Scale factor beta calculation |
| 21 | + * max_cwnd = snd_cwnd * beta |
| 22 | + */ |
| 23 | + #define BICTCP_HZ 10 /* BIC HZ 2^10 = 1024 */ |
| 24 | + |
| 25 | ++#define NETLINK_TESTFAMILY 31 |
| 26 | ++ |
| 27 | + /* Two methods of hybrid slow start */ |
| 28 | + #define HYSTART_ACK_TRAIN 0x1 |
| 29 | + #define HYSTART_DELAY 0x2 |
| 30 | +@@ -80,6 +93,41 @@ MODULE_PARM_DESC(hystart_low_window, "lower bound cwnd for hybrid slow start"); |
| 31 | + module_param(hystart_ack_delta_us, int, 0644); |
| 32 | + MODULE_PARM_DESC(hystart_ack_delta_us, "spacing between ack's indicating train (usecs)"); |
| 33 | + |
| 34 | ++struct sock *socket; |
| 35 | ++ |
| 36 | ++bool handover_status = false; |
| 37 | ++ |
| 38 | ++static void nl_receive_handover_status(struct sk_buff *skb) { |
| 39 | ++ struct nlmsghdr *nlh = (struct nlmsghdr *) skb->data; |
| 40 | ++ char *singal = (char*) nlmsg_data(nlh); |
| 41 | ++ if (singal[0] == '1') { |
| 42 | ++ handover_status = true; |
| 43 | ++ printk("handover status changed to 1\n"); |
| 44 | ++ } else { |
| 45 | ++ handover_status = false; |
| 46 | ++ printk("handover status changed to 0\n"); |
| 47 | ++ } |
| 48 | ++} |
| 49 | ++ |
| 50 | ++static int socket_init(void) { |
| 51 | ++ struct netlink_kernel_cfg config = { |
| 52 | ++ .input = nl_receive_handover_status, |
| 53 | ++ }; |
| 54 | ++ |
| 55 | ++ socket = netlink_kernel_create(&init_net, NETLINK_TESTFAMILY, &config); |
| 56 | ++ if (socket == NULL) { |
| 57 | ++ return -1; |
| 58 | ++ } |
| 59 | ++ |
| 60 | ++ return 0; |
| 61 | ++} |
| 62 | ++ |
| 63 | ++static void socket_exit(void) { |
| 64 | ++ if (socket) { |
| 65 | ++ netlink_kernel_release(socket); |
| 66 | ++ } |
| 67 | ++} |
| 68 | ++ |
| 69 | + /* BIC TCP Parameters */ |
| 70 | + struct bictcp { |
| 71 | + u32 cnt; /* increase cwnd by 1 after ACKs */ |
| 72 | +@@ -251,8 +299,15 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd, u32 acked) |
| 73 | + /* Compute new K based on |
| 74 | + * (wmax-cwnd) * (srtt>>3 / HZ) / c * 2^(3*bictcp_HZ) |
| 75 | + */ |
| 76 | +- ca->bic_K = cubic_root(cube_factor |
| 77 | +- * (ca->last_max_cwnd - cwnd)); |
| 78 | ++ // shrink the recovery time |
| 79 | ++ if (handover_status) { |
| 80 | ++ // handover is happening, so drastically reduce the recovery time K to last max point |
| 81 | ++ ca->bic_K = cubic_root(cube_factor * (ca->last_max_cwnd - cwnd)) - (cubic_root(cube_factor * (ca->last_max_cwnd - cwnd)) * 8 / 9); |
| 82 | ++ printk("SATCP triggered in bictcp_update!\n"); |
| 83 | ++ } else { |
| 84 | ++ ca->bic_K = cubic_root(cube_factor * (ca->last_max_cwnd - cwnd)); |
| 85 | ++ } |
| 86 | ++ |
| 87 | + ca->bic_origin_point = ca->last_max_cwnd; |
| 88 | + } |
| 89 | + } |
| 90 | +@@ -364,9 +419,14 @@ static u32 bictcp_recalc_ssthresh(struct sock *sk) |
| 91 | + |
| 92 | + static void bictcp_state(struct sock *sk, u8 new_state) |
| 93 | + { |
| 94 | ++ // ignore packet loss |
| 95 | + if (new_state == TCP_CA_Loss) { |
| 96 | +- bictcp_reset(inet_csk_ca(sk)); |
| 97 | +- bictcp_hystart_reset(sk); |
| 98 | ++ if (!handover_status) { |
| 99 | ++ bictcp_reset(inet_csk_ca(sk)); |
| 100 | ++ bictcp_hystart_reset(sk); |
| 101 | ++ } else { |
| 102 | ++ printk("SATCP triggered in bictcp_state!\n"); |
| 103 | ++ } |
| 104 | + } |
| 105 | + } |
| 106 | + |
| 107 | +@@ -494,6 +554,7 @@ static struct tcp_congestion_ops cubictcp __read_mostly = { |
| 108 | + |
| 109 | + static int __init cubictcp_register(void) |
| 110 | + { |
| 111 | ++ socket_init(); |
| 112 | + BUILD_BUG_ON(sizeof(struct bictcp) > ICSK_CA_PRIV_SIZE); |
| 113 | + |
| 114 | + /* Precompute a bunch of the scaling factors that are used per-packet |
| 115 | +@@ -530,6 +591,7 @@ static int __init cubictcp_register(void) |
| 116 | + static void __exit cubictcp_unregister(void) |
| 117 | + { |
| 118 | + tcp_unregister_congestion_control(&cubictcp); |
| 119 | ++ socket_exit(); |
| 120 | + } |
| 121 | + |
| 122 | + module_init(cubictcp_register); |
0 commit comments