Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/cc/cc_chd.c
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | |||||
#include <netinet/khelp/h_ertt.h> | #include <netinet/khelp/h_ertt.h> | ||||
/* | /* | ||||
* Private signal type for rate based congestion signal. | * Private signal type for rate based congestion signal. | ||||
* See <netinet/cc.h> for appropriate bit-range to use for private signals. | * See <netinet/cc.h> for appropriate bit-range to use for private signals. | ||||
*/ | */ | ||||
#define CC_CHD_DELAY 0x02000000 | #define CC_CHD_DELAY 0x02000000 | ||||
/* Largest possible number returned by random(). */ | /* Largest possible number returned by arc4random(). */ | ||||
#define RANDOM_MAX INT_MAX | #define RANDOM_MAX UINT_MAX | ||||
cem: Isn’t there some header this code can include for the real RANDOM_MAX? I don’t like defining… | |||||
Done Inline ActionsThis is defined near to where it is used, and while it should be using RAND_MAX for random(), I see why any such value depends on the specific randomness function used. It probably should be in a single header if the code author had set on use it, with the corresponding function, consistently all over the code . pfg: This is defined near to where it is used, and while it should be using RAND_MAX for random(), I… | |||||
static void chd_ack_received(struct cc_var *ccv, uint16_t ack_type); | static void chd_ack_received(struct cc_var *ccv, uint16_t ack_type); | ||||
static void chd_cb_destroy(struct cc_var *ccv); | static void chd_cb_destroy(struct cc_var *ccv); | ||||
static int chd_cb_init(struct cc_var *ccv); | static int chd_cb_init(struct cc_var *ccv); | ||||
static void chd_cong_signal(struct cc_var *ccv, uint32_t signal_type); | static void chd_cong_signal(struct cc_var *ccv, uint32_t signal_type); | ||||
static void chd_conn_init(struct cc_var *ccv); | static void chd_conn_init(struct cc_var *ccv); | ||||
static int chd_mod_init(void); | static int chd_mod_init(void); | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
* Probabilistic backoff function. Returns 1 if we should backoff or 0 | * Probabilistic backoff function. Returns 1 if we should backoff or 0 | ||||
* otherwise. The calculation of p is similar to the calculation of p in cc_hd. | * otherwise. The calculation of p is similar to the calculation of p in cc_hd. | ||||
*/ | */ | ||||
static __inline int | static __inline int | ||||
should_backoff(int qdly, int maxqdly, struct chd *chd_data) | should_backoff(int qdly, int maxqdly, struct chd *chd_data) | ||||
{ | { | ||||
unsigned long p, rand; | unsigned long p, rand; | ||||
rand = random(); | rand = arc4random(); | ||||
Not Done Inline ActionsDitto cc_cdg remarks. cem: Ditto cc_cdg remarks. | |||||
Done Inline ActionsYeah... again this on its own differential now. pfg: Yeah... again this on its own differential now. | |||||
if (qdly < V_chd_qthresh) { | if (qdly < V_chd_qthresh) { | ||||
chd_data->loss_compete = 0; | chd_data->loss_compete = 0; | ||||
p = (((RANDOM_MAX / 100) * V_chd_pmax) / | p = (((RANDOM_MAX / 100) * V_chd_pmax) / | ||||
(V_chd_qthresh - V_chd_qmin)) * | (V_chd_qthresh - V_chd_qmin)) * | ||||
(qdly - V_chd_qmin); | (qdly - V_chd_qmin); | ||||
} else { | } else { | ||||
if (qdly > V_chd_qthresh) { | if (qdly > V_chd_qthresh) { | ||||
▲ Show 20 Lines • Show All 327 Lines • Show Last 20 Lines |
Isn’t there some header this code can include for the real RANDOM_MAX? I don’t like defining well known constants like this in arbitrary C files.