Skip to content

Commit

Permalink
change derand to deter
Browse files Browse the repository at this point in the history
  • Loading branch information
liyuliang001 committed Apr 17, 2019
1 parent 9bcdd82 commit cdeb2d9
Show file tree
Hide file tree
Showing 23 changed files with 972 additions and 972 deletions.
10 changes: 5 additions & 5 deletions drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
#include <net/pkt_cls.h>
#include <net/tc_act/tc_gact.h>

/* derand */
#include <net/derand_ops.h>
/* deter */
#include <net/deter_ops.h>

#ifdef CONFIG_OF
#include <linux/of_net.h>
Expand Down Expand Up @@ -7813,9 +7813,9 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
}

skb_tx_timestamp(skb);
#if DERAND_ENABLE
if (skb->sk && skb->sk->recorder && derand_record_ops.tx_stamp){
derand_record_ops.tx_stamp(skb);
#if DETER_ENABLE
if (skb->sk && skb->sk->recorder && deter_record_ops.tx_stamp){
deter_record_ops.tx_stamp(skb);
}
#endif

Expand Down
10 changes: 5 additions & 5 deletions drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
#include <linux/if_vlan.h>
#include <linux/prefetch.h>

/* derand */
#include <net/derand_ops.h>
/* deter */
#include <net/deter_ops.h>

#include "ixgbevf.h"

Expand Down Expand Up @@ -3661,9 +3661,9 @@ static int ixgbevf_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
first->tx_flags = tx_flags;
first->protocol = vlan_get_protocol(skb);

#if DERAND_ENABLE
if (skb->sk && skb->sk->recorder && derand_record_ops.tx_stamp){
derand_record_ops.tx_stamp(skb);
#if DETER_ENABLE
if (skb->sk && skb->sk->recorder && deter_record_ops.tx_stamp){
deter_record_ops.tx_stamp(skb);
}
#endif
tso = ixgbevf_tso(tx_ring, first, &hdr_len);
Expand Down
6 changes: 0 additions & 6 deletions include/net/derand.h

This file was deleted.

6 changes: 6 additions & 0 deletions include/net/deter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef _NET_DETER_H
#define _NET_DETER_H

#define DETER_ENABLE 1

#endif /* _NET_DETER_H */
108 changes: 54 additions & 54 deletions include/net/derand_ops.h → include/net/deter_ops.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#ifndef _NET_DERAND_OPS_H
#define _NET_DERAND_OPS_H
#ifndef _NET_DETER_OPS_H
#define _NET_DETER_OPS_H

#include <net/derand.h>
#include <net/deter.h>
#include <net/sock.h>
#include <linux/socket.h>
#include <linux/jiffies.h>

#if DERAND_ENABLE
#if DETER_ENABLE

struct derand_record_ops{
struct deter_record_ops{
/* Create a recorder at server side */
void (*server_recorder_create)(struct sock*, struct sk_buff *skb);

Expand Down Expand Up @@ -136,41 +136,41 @@ struct derand_record_ops{
void (*tx_stamp)(const struct sk_buff *skb);
};

extern struct derand_record_ops derand_record_ops_default;
extern struct derand_record_ops derand_record_ops;
extern struct deter_record_ops deter_record_ops_default;
extern struct deter_record_ops deter_record_ops;

/* A read to jiffies. ID is diff for each location of read in the code */
static inline unsigned long derand_jiffies(const struct sock *sk, int id){
static inline unsigned long deter_jiffies(const struct sock *sk, int id){
unsigned long res;
// check if in replay mode
if (sk->replayer && derand_record_ops.replay_jiffies)
return derand_record_ops.replay_jiffies(sk, id);
if (sk->replayer && deter_record_ops.replay_jiffies)
return deter_record_ops.replay_jiffies(sk, id);

// not in replay mode
res = jiffies;
if (sk->recorder && derand_record_ops.read_jiffies)
derand_record_ops.read_jiffies(sk, res, id);
if (sk->recorder && deter_record_ops.read_jiffies)
deter_record_ops.read_jiffies(sk, res, id);
return res;
}

/* A read to tcp_time_stamp. ID is diff for each location of read in the code */
static inline u32 derand_tcp_time_stamp(const struct sock *sk, int id){
static inline u32 deter_tcp_time_stamp(const struct sock *sk, int id){
unsigned long res;
// check if in replay mode
if (sk->replayer && derand_record_ops.replay_tcp_time_stamp)
return (u32)derand_record_ops.replay_tcp_time_stamp(sk, id);
if (sk->replayer && deter_record_ops.replay_tcp_time_stamp)
return (u32)deter_record_ops.replay_tcp_time_stamp(sk, id);

// not in replay mode
res = jiffies;
if (sk->recorder && derand_record_ops.read_tcp_time_stamp)
derand_record_ops.read_tcp_time_stamp(sk, res, id);
if (sk->recorder && deter_record_ops.read_tcp_time_stamp)
deter_record_ops.read_tcp_time_stamp(sk, res, id);
return (u32)res;
}

extern int tcp_memory_pressure;

/* Copy of tcp_under_memory_pressure */
static inline bool derand_copied_tcp_under_memory_pressure(const struct sock *sk)
static inline bool deter_copied_tcp_under_memory_pressure(const struct sock *sk)
{
if (mem_cgroup_sockets_enabled && sk->sk_cgrp)
return !!sk->sk_cgrp->memory_pressure;
Expand All @@ -179,107 +179,107 @@ static inline bool derand_copied_tcp_under_memory_pressure(const struct sock *sk
}

/* A read to tcp_under_memory_pressure */
static inline bool derand_tcp_under_memory_pressure(const struct sock *sk){
static inline bool deter_tcp_under_memory_pressure(const struct sock *sk){
bool ret;
// check if in replay mode
if (sk->replayer && derand_record_ops.replay_tcp_under_memory_pressure)
return derand_record_ops.replay_tcp_under_memory_pressure(sk);
if (sk->replayer && deter_record_ops.replay_tcp_under_memory_pressure)
return deter_record_ops.replay_tcp_under_memory_pressure(sk);

// not in replay mode
ret = derand_copied_tcp_under_memory_pressure(sk);
ret = deter_copied_tcp_under_memory_pressure(sk);

// if in record mode
if (sk->recorder && derand_record_ops.tcp_under_memory_pressure)
derand_record_ops.tcp_under_memory_pressure(sk, ret);
if (sk->recorder && deter_record_ops.tcp_under_memory_pressure)
deter_record_ops.tcp_under_memory_pressure(sk, ret);
return ret;
}

/* a read to sk_under_memory_pressure */
static inline bool derand_sk_under_memory_pressure(const struct sock *sk){
static inline bool deter_sk_under_memory_pressure(const struct sock *sk){
bool ret;
// check if in replay mode
if (sk->replayer && derand_record_ops.replay_sk_under_memory_pressure)
return derand_record_ops.replay_sk_under_memory_pressure(sk);
if (sk->replayer && deter_record_ops.replay_sk_under_memory_pressure)
return deter_record_ops.replay_sk_under_memory_pressure(sk);

// not in replay mode
ret = sk_under_memory_pressure(sk);

// if in record mode
if (sk->recorder && derand_record_ops.sk_under_memory_pressure)
derand_record_ops.sk_under_memory_pressure(sk, ret);
if (sk->recorder && deter_record_ops.sk_under_memory_pressure)
deter_record_ops.sk_under_memory_pressure(sk, ret);
return ret;
}

/* A call to sk_memory_allocated */
static inline long derand_sk_memory_allocated(const struct sock *sk){
static inline long deter_sk_memory_allocated(const struct sock *sk){
long ret;
// check if in replay mode
if (sk->replayer && derand_record_ops.replay_sk_memory_allocated)
return derand_record_ops.replay_sk_memory_allocated(sk);
if (sk->replayer && deter_record_ops.replay_sk_memory_allocated)
return deter_record_ops.replay_sk_memory_allocated(sk);

// not in replay mode
ret = sk_memory_allocated(sk);

// if in record mode
if (sk->recorder && derand_record_ops.sk_memory_allocated)
derand_record_ops.sk_memory_allocated(sk, ret);
if (sk->recorder && deter_record_ops.sk_memory_allocated)
deter_record_ops.sk_memory_allocated(sk, ret);
return ret;
}

/* A call to sk_sockets_allocated_read_positive */
static inline int derand_sk_sockets_allocated_read_positive(struct sock *sk){
static inline int deter_sk_sockets_allocated_read_positive(struct sock *sk){
int ret;
// check if in replay mode
if (sk->replayer && derand_record_ops.replay_sk_socket_allocated_read_positive)
return derand_record_ops.replay_sk_socket_allocated_read_positive(sk);
if (sk->replayer && deter_record_ops.replay_sk_socket_allocated_read_positive)
return deter_record_ops.replay_sk_socket_allocated_read_positive(sk);

// not in replay mode
ret = sk_sockets_allocated_read_positive(sk);

// if in record mode
if (sk->recorder && derand_record_ops.sk_sockets_allocated_read_positive)
derand_record_ops.sk_sockets_allocated_read_positive(sk, ret);
if (sk->recorder && deter_record_ops.sk_sockets_allocated_read_positive)
deter_record_ops.sk_sockets_allocated_read_positive(sk, ret);
return ret;
}

/* A call to skb_mstamp_get */
static inline void derand_skb_mstamp_get(struct sock *sk, struct skb_mstamp *cl, int loc){
static inline void deter_skb_mstamp_get(struct sock *sk, struct skb_mstamp *cl, int loc){
// check if in replay mode
if (sk->replayer && derand_record_ops.skb_mstamp_get){
derand_record_ops.skb_mstamp_get(sk, cl, loc);
if (sk->replayer && deter_record_ops.skb_mstamp_get){
deter_record_ops.skb_mstamp_get(sk, cl, loc);
return;
}

// not in replay mode
skb_mstamp_get(cl);

// if in record mode
if (sk->recorder && derand_record_ops.skb_mstamp_get)
derand_record_ops.skb_mstamp_get(sk, cl, loc);
if (sk->recorder && deter_record_ops.skb_mstamp_get)
deter_record_ops.skb_mstamp_get(sk, cl, loc);
}

/* A call to skb_still_in_host_queue */
#define derand_skb_still_in_host_queue(sk, skb, call) \
#define deter_skb_still_in_host_queue(sk, skb, call) \
({ \
bool ret; \
if (sk->replayer && derand_record_ops.replay_skb_still_in_host_queue) \
ret = derand_record_ops.replay_skb_still_in_host_queue(sk, skb); \
if (sk->replayer && deter_record_ops.replay_skb_still_in_host_queue) \
ret = deter_record_ops.replay_skb_still_in_host_queue(sk, skb); \
else { \
ret = (call); \
if (sk->recorder && derand_record_ops.record_skb_still_in_host_queue) \
derand_record_ops.record_skb_still_in_host_queue(sk, ret); \
if (sk->recorder && deter_record_ops.record_skb_still_in_host_queue) \
deter_record_ops.record_skb_still_in_host_queue(sk, ret); \
} \
ret; \
})

/* A general event */
static inline void derand_general_event(const struct sock *sk, int loc, u64 data){
if (derand_record_ops.general_event){
static inline void deter_general_event(const struct sock *sk, int loc, u64 data){
if (deter_record_ops.general_event){
if (sk->recorder || sk->replayer)
derand_record_ops.general_event(sk, loc, data);
deter_record_ops.general_event(sk, loc, data);
}
}

#endif /* DERAND_ENABLE */
#endif /* DETER_ENABLE */

#endif /* _NET_DERAND_OPS_H */
#endif /* _NET_DETER_OPS_H */
16 changes: 8 additions & 8 deletions include/net/inet_connection_sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

#include <net/inet_sock.h>
#include <net/request_sock.h>
/* DERAND */
#include <net/derand_ops.h>
/* DETER */
#include <net/deter_ops.h>

#define INET_CSK_DEBUG 1

Expand Down Expand Up @@ -226,8 +226,8 @@ static inline void inet_csk_reset_xmit_timer(struct sock *sk, const int what,
{
struct inet_connection_sock *icsk = inet_csk(sk);

#if DERAND_ENABLE
derand_advanced_event(sk, DR_INET_CSK_RESET_XMIT_TIMER, 0, 0b011, what, when, max_when);
#if DETER_ENABLE
deter_advanced_event(sk, DR_INET_CSK_RESET_XMIT_TIMER, 0, 0b011, what, when, max_when);
#endif
if (when > max_when) {
#ifdef INET_CSK_DEBUG
Expand All @@ -240,16 +240,16 @@ static inline void inet_csk_reset_xmit_timer(struct sock *sk, const int what,
if (what == ICSK_TIME_RETRANS || what == ICSK_TIME_PROBE0 ||
what == ICSK_TIME_EARLY_RETRANS || what == ICSK_TIME_LOSS_PROBE) {
icsk->icsk_pending = what;
#if DERAND_ENABLE
icsk->icsk_timeout = derand_jiffies(sk, 10) + when;
#if DETER_ENABLE
icsk->icsk_timeout = deter_jiffies(sk, 10) + when;
#else
icsk->icsk_timeout = jiffies + when;
#endif
sk_reset_timer(sk, &icsk->icsk_retransmit_timer, icsk->icsk_timeout);
} else if (what == ICSK_TIME_DACK) {
icsk->icsk_ack.pending |= ICSK_ACK_TIMER;
#if DERAND_ENABLE
icsk->icsk_ack.timeout = derand_jiffies(sk, 11) + when;
#if DETER_ENABLE
icsk->icsk_ack.timeout = deter_jiffies(sk, 11) + when;
#else
icsk->icsk_ack.timeout = jiffies + when;
#endif
Expand Down
Loading

0 comments on commit cdeb2d9

Please sign in to comment.