Skip to content

Commit

Permalink
Disable aligning consecutive assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
kyechou committed Jul 19, 2024
1 parent 0cf973f commit 26e7228
Show file tree
Hide file tree
Showing 68 changed files with 379 additions and 379 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ BasedOnStyle: Google
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignArrayOfStructures: Left
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: Consecutive
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: AcrossEmptyLines
Expand Down
154 changes: 77 additions & 77 deletions src/configparser.cpp

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/configparser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ class ConfigParser {
void parse_conn_spec(ConnSpec &, const toml::table &, const Network &);

public:
ConfigParser() = default;
ConfigParser(const ConfigParser &) = delete;
ConfigParser(ConfigParser &&) = delete;
ConfigParser() = default;
ConfigParser(const ConfigParser &) = delete;
ConfigParser(ConfigParser &&) = delete;
ConfigParser &operator=(const ConfigParser &) = delete;
ConfigParser &operator=(ConfigParser &&) = delete;
ConfigParser &operator=(ConfigParser &&) = delete;

void parse(const std::string &filename, Plankton &plankton);
void estimate_pkt_lat(int num_injections);
Expand Down
2 changes: 1 addition & 1 deletion src/conn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Connection {
uint16_t dst_port);
Connection(const Packet &, Node *src_node);
Connection(const Connection &) = default;
Connection(Connection &&) = default;
Connection(Connection &&) = default;

std::string to_string() const;
void init(size_t conn_idx) const;
Expand Down
4 changes: 2 additions & 2 deletions src/dockerapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ DockerAPI_GLOBAL::~DockerAPI_GLOBAL() {
curl_global_cleanup();
}

const string DockerAPI::_api_version = "v1.42";
const string DockerAPI::_api_version = "v1.42";
const Document DockerAPI::_empty_json = {};
const DockerAPI_GLOBAL DockerAPI::_global_raii;

Expand All @@ -26,7 +26,7 @@ Document DockerAPI::send_curl_request(method method,
const Document &request_body) {

// curl: set request URL and method
string url = this->_uri_prefix + path;
string url = this->_uri_prefix + path;
string method_str = method_to_str(method);
curl_easy_setopt(_curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(_curl, CURLOPT_CUSTOMREQUEST, method_str.c_str());
Expand Down
24 changes: 12 additions & 12 deletions src/driver/docker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void Docker::wait_for_dpdk_interfaces() const {
// Abort if some interfaces are not created after some time.
if (!if_names.empty()) {
string remaining_intfs = *if_names.begin();
auto it = if_names.begin();
auto it = if_names.begin();
++it;
for (; it != if_names.end(); ++it) {
remaining_intfs += ", " + *it;
Expand Down Expand Up @@ -152,10 +152,10 @@ int Docker::tap_open_dpdk(const string &if_name) const {

struct sockaddr_ll saddr;
memset(&saddr, 0, sizeof(saddr));
saddr.sll_family = AF_PACKET;
saddr.sll_family = AF_PACKET;
saddr.sll_protocol = htons(ETH_P_IP);
saddr.sll_ifindex = ifr.ifr_ifindex;
saddr.sll_pkttype = PACKET_HOST;
saddr.sll_ifindex = ifr.ifr_ifindex;
saddr.sll_pkttype = PACKET_HOST;

if (bind(sock, (struct sockaddr *)&saddr, sizeof(saddr)) == -1) {
close(sock);
Expand Down Expand Up @@ -343,10 +343,10 @@ void Docker::set_arp_cache() {

// Set permanent arp cache entries
struct arpreq arp;
arp.arp_pa = {AF_INET, {0}};
arp.arp_ha = {ARPHRD_ETHER, {0}};
arp.arp_flags = ATF_COM | ATF_PERM;
arp.arp_netmask = {AF_UNSPEC, {0}};
arp.arp_pa = {AF_INET, {0}};
arp.arp_ha = {ARPHRD_ETHER, {0}};
arp.arp_flags = ATF_COM | ATF_PERM;
arp.arp_netmask = {AF_UNSPEC, {0}};
uint8_t id_mac[6] = ID_ETH_ADDR;
memcpy(arp.arp_ha.sa_data, id_mac, 6);

Expand Down Expand Up @@ -376,7 +376,7 @@ void Docker::set_epoll_events() {
struct epoll_event event;

for (const auto &[intf, tapfd] : this->_tapfds) {
event.events = EPOLLIN;
event.events = EPOLLIN;
event.data.ptr = intf;
if (epoll_ctl(_epollfd, EPOLL_CTL_ADD, tapfd, &event) < 0) {
logger.error("epoll_ctl", errno);
Expand Down Expand Up @@ -563,7 +563,7 @@ void Docker::init() {
make_unique<pcpp::PcapFileWriterDevice>(
pcapFn, pcpp::LINKTYPE_ETHERNET));
auto &pcapLogger = this->_pcap_loggers.at(intf);
bool appendMode = fs::exists(pcapFn);
bool appendMode = fs::exists(pcapFn);
if (!pcapLogger->open(appendMode)) {
logger.error("Failed to open " + pcapFn);
}
Expand Down Expand Up @@ -641,7 +641,7 @@ size_t Docker::inject_packet(const Packet &pkt) {
Net::get().serialize(&buf, &len, pkt, src_mac, dst_mac);

// Write to the tap device fd
int fd = this->_tapfds.at(pkt.get_intf());
int fd = this->_tapfds.at(pkt.get_intf());
ssize_t nwrite = write(fd, buf, len);
if (nwrite < 0) {
logger.error("Packet injection failed", errno);
Expand Down Expand Up @@ -681,7 +681,7 @@ list<Packet> Docker::read_packets() const {
// Read from available tap fds
for (int i = 0; i < nfds; ++i) {
Interface *interface = static_cast<Interface *>(_events[i].data.ptr);
int tapfd = this->_tapfds.at(interface);
int tapfd = this->_tapfds.at(interface);
PktBuffer pktbuff(interface);
ssize_t nread;
if ((nread = read(tapfd, pktbuff.get_buffer(), pktbuff.get_len())) <
Expand Down
10 changes: 5 additions & 5 deletions src/driver/driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class Driver {
public:
virtual ~Driver() = default;

virtual void init() = 0;
virtual void reset() = 0;
virtual void pause() = 0;
virtual void unpause() = 0;
virtual size_t inject_packet(const Packet &) = 0;
virtual void init() = 0;
virtual void reset() = 0;
virtual void pause() = 0;
virtual void unpause() = 0;
virtual size_t inject_packet(const Packet &) = 0;
virtual std::list<Packet> read_packets() const = 0;
};
46 changes: 23 additions & 23 deletions src/dropmon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@ DropMon::DropMon() :
_dm_sock(nullptr),
_stop_dm_thread(false),
_drop_ts(0) {
_net_dm_policy[NET_DM_ATTR_UNSPEC] = {NLA_UNSPEC, 0, 0};
_net_dm_policy[NET_DM_ATTR_ALERT_MODE] = {NLA_U8, 0, 0};
_net_dm_policy[NET_DM_ATTR_PC] = {NLA_U64, 0, 0};
_net_dm_policy[NET_DM_ATTR_SYMBOL] = {NLA_STRING, 0, 0};
_net_dm_policy[NET_DM_ATTR_IN_PORT] = {NLA_NESTED, 0, 0};
_net_dm_policy[NET_DM_ATTR_TIMESTAMP] = {NLA_U64, 0, 0};
_net_dm_policy[NET_DM_ATTR_PROTO] = {NLA_U16, 0, 0};
_net_dm_policy[NET_DM_ATTR_PAYLOAD] = {NLA_UNSPEC, 0, 0};
_net_dm_policy[NET_DM_ATTR_PAD] = {NLA_UNSPEC, 0, 0};
_net_dm_policy[NET_DM_ATTR_TRUNC_LEN] = {NLA_U32, 0, 0};
_net_dm_policy[NET_DM_ATTR_ORIG_LEN] = {NLA_U32, 0, 0};
_net_dm_policy[NET_DM_ATTR_QUEUE_LEN] = {NLA_U32, 0, 0};
_net_dm_policy[NET_DM_ATTR_STATS] = {NLA_NESTED, 0, 0};
_net_dm_policy[NET_DM_ATTR_HW_STATS] = {NLA_NESTED, 0, 0};
_net_dm_policy[NET_DM_ATTR_ORIGIN] = {NLA_U16, 0, 0};
_net_dm_policy[NET_DM_ATTR_UNSPEC] = {NLA_UNSPEC, 0, 0};
_net_dm_policy[NET_DM_ATTR_ALERT_MODE] = {NLA_U8, 0, 0};
_net_dm_policy[NET_DM_ATTR_PC] = {NLA_U64, 0, 0};
_net_dm_policy[NET_DM_ATTR_SYMBOL] = {NLA_STRING, 0, 0};
_net_dm_policy[NET_DM_ATTR_IN_PORT] = {NLA_NESTED, 0, 0};
_net_dm_policy[NET_DM_ATTR_TIMESTAMP] = {NLA_U64, 0, 0};
_net_dm_policy[NET_DM_ATTR_PROTO] = {NLA_U16, 0, 0};
_net_dm_policy[NET_DM_ATTR_PAYLOAD] = {NLA_UNSPEC, 0, 0};
_net_dm_policy[NET_DM_ATTR_PAD] = {NLA_UNSPEC, 0, 0};
_net_dm_policy[NET_DM_ATTR_TRUNC_LEN] = {NLA_U32, 0, 0};
_net_dm_policy[NET_DM_ATTR_ORIG_LEN] = {NLA_U32, 0, 0};
_net_dm_policy[NET_DM_ATTR_QUEUE_LEN] = {NLA_U32, 0, 0};
_net_dm_policy[NET_DM_ATTR_STATS] = {NLA_NESTED, 0, 0};
_net_dm_policy[NET_DM_ATTR_HW_STATS] = {NLA_NESTED, 0, 0};
_net_dm_policy[NET_DM_ATTR_ORIGIN] = {NLA_U16, 0, 0};
_net_dm_policy[NET_DM_ATTR_HW_TRAP_GROUP_NAME] = {NLA_STRING, 0, 0};
_net_dm_policy[NET_DM_ATTR_HW_TRAP_NAME] = {NLA_STRING, 0, 0};
_net_dm_policy[NET_DM_ATTR_HW_ENTRIES] = {NLA_NESTED, 0, 0};
_net_dm_policy[NET_DM_ATTR_HW_ENTRY] = {NLA_NESTED, 0, 0};
_net_dm_policy[NET_DM_ATTR_HW_TRAP_COUNT] = {NLA_U32, 0, 0};
_net_dm_policy[NET_DM_ATTR_SW_DROPS] = {NLA_FLAG, 0, 0};
_net_dm_policy[NET_DM_ATTR_HW_DROPS] = {NLA_FLAG, 0, 0};
_net_dm_policy[NET_DM_ATTR_HW_TRAP_NAME] = {NLA_STRING, 0, 0};
_net_dm_policy[NET_DM_ATTR_HW_ENTRIES] = {NLA_NESTED, 0, 0};
_net_dm_policy[NET_DM_ATTR_HW_ENTRY] = {NLA_NESTED, 0, 0};
_net_dm_policy[NET_DM_ATTR_HW_TRAP_COUNT] = {NLA_U32, 0, 0};
_net_dm_policy[NET_DM_ATTR_SW_DROPS] = {NLA_FLAG, 0, 0};
_net_dm_policy[NET_DM_ATTR_HW_DROPS] = {NLA_FLAG, 0, 0};
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)
_net_dm_policy[NET_DM_ATTR_FLOW_ACTION_COOKIE] = {NLA_UNSPEC, 0, 0};
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
Expand Down Expand Up @@ -158,7 +158,7 @@ void DropMon::start_listening_for(const Packet &pkt,
// Reset dropmon variables
unique_lock<mutex> lck(_mtx);
_target_pkt = pkt;
_drop_ts = 0;
_drop_ts = 0;
lck.unlock();

// Set up the drop listener thread (block all signals)
Expand Down Expand Up @@ -337,7 +337,7 @@ Packet DropMon::recv_msg(struct nl_sock *sock, uint64_t &ts) const {
goto out_free;
}
// deserialize packet
payload = nla_data(attrs[NET_DM_ATTR_PAYLOAD]);
payload = nla_data(attrs[NET_DM_ATTR_PAYLOAD]);
payloadlen = nla_len(attrs[NET_DM_ATTR_PAYLOAD]);
Net::get().deserialize(pkt, (const uint8_t *)payload, payloadlen);

Expand Down
6 changes: 3 additions & 3 deletions src/dropmon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class DropMon : public DropDetection {

public:
// Disable the copy/move constructors and the assignment operators
DropMon(const DropMon &) = delete;
DropMon(DropMon &&) = delete;
DropMon(const DropMon &) = delete;
DropMon(DropMon &&) = delete;
DropMon &operator=(const DropMon &) = delete;
DropMon &operator=(DropMon &&) = delete;
DropMon &operator=(DropMon &&) = delete;
~DropMon() override;

static DropMon &get();
Expand Down
18 changes: 9 additions & 9 deletions src/droptimeout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ void DropTimeout::init() {
}

void DropTimeout::reset() {
_lat_avg = chrono::microseconds();
_lat_mdev = chrono::microseconds();
_timeout = chrono::microseconds();
_lat_avg = chrono::microseconds();
_lat_mdev = chrono::microseconds();
_timeout = chrono::microseconds();
_has_initial_estimate = false;
_nprocs = 0;
_mdev_scalar = 0;
_nprocs = 0;
_mdev_scalar = 0;
}

/**
Expand All @@ -67,11 +67,11 @@ void DropTimeout::reset() {
* @param nprocs the number of parallel processes for the current invariant
*/
void DropTimeout::adjust_latency_estimate_by_nprocs(int nprocs) {
_nprocs = nprocs;
_nprocs = nprocs;
static const int total_cores = thread::hardware_concurrency();
double load = double(_nprocs) / total_cores;
_mdev_scalar = max(5.0, ceil(sqrt(_nprocs) * 2 * load));
_timeout = _lat_avg + _lat_mdev * _mdev_scalar;
double load = double(_nprocs) / total_cores;
_mdev_scalar = max(5.0, ceil(sqrt(_nprocs) * 2 * load));
_timeout = _lat_avg + _lat_mdev * _mdev_scalar;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/droptimeout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class DropTimeout {

public:
// Disable the copy/move constructors and the assignment operators
DropTimeout(const DropTimeout &) = delete;
DropTimeout(DropTimeout &&) = delete;
DropTimeout(const DropTimeout &) = delete;
DropTimeout(DropTimeout &&) = delete;
DropTimeout &operator=(const DropTimeout &) = delete;
DropTimeout &operator=(DropTimeout &&) = delete;
DropTimeout &operator=(DropTimeout &&) = delete;

static DropTimeout &get();

Expand Down
12 changes: 6 additions & 6 deletions src/droptrace.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static inline struct net *skb_net(const struct sk_buff *skb) {

static inline unsigned int skb_netns_ino(const struct sk_buff *skb) {
unsigned int ino = 0;
struct net *net = skb_net(skb);
struct net *net = skb_net(skb);

if (net) {
BPF_CORE_READ_INTO(&ino, net, ns.inum);
Expand All @@ -172,7 +172,7 @@ static inline int my_memcmp(const void *s1, const void *s2, size_t n) {
SEC("tracepoint/skb/kfree_skb")
int tracepoint__kfree_skb(struct trace_event_raw_kfree_skb *args) {
struct drop_data *target_pkt = NULL;
u32 target_pkt_key = 0;
u32 target_pkt_key = 0;
target_pkt = (struct drop_data *)bpf_map_lookup_elem(&target_packet,
&target_pkt_key);

Expand All @@ -182,7 +182,7 @@ int tracepoint__kfree_skb(struct trace_event_raw_kfree_skb *args) {
}

// Get sk_buff and skip event if the sk_buff is empty
struct sk_buff *skb = NULL;
struct sk_buff *skb = NULL;
unsigned int skb_len = 0;
BPF_CORE_READ_INTO(&skb, args, skbaddr);
BPF_CORE_READ_INTO(&skb_len, skb, len);
Expand All @@ -193,8 +193,8 @@ int tracepoint__kfree_skb(struct trace_event_raw_kfree_skb *args) {

// Reserve drop data for this event
struct drop_data *data = NULL;
data = (struct drop_data *)bpf_ringbuf_reserve(&events,
sizeof(struct drop_data), 0);
data = (struct drop_data *)bpf_ringbuf_reserve(&events,
sizeof(struct drop_data), 0);
if (!data) {
return 0;
}
Expand Down Expand Up @@ -222,7 +222,7 @@ int tracepoint__kfree_skb(struct trace_event_raw_kfree_skb *args) {

// L2
if (skb_mac_header_was_set(skb)) {
uint8_t id_mac[6] = ID_ETH_ADDR;
uint8_t id_mac[6] = ID_ETH_ADDR;
struct ethhdr *eth = eth_hdr(skb);
BPF_CORE_READ_INTO(&data->eth_dst_addr, eth, h_dest);
BPF_CORE_READ_INTO(&data->eth_src_addr, eth, h_source);
Expand Down
14 changes: 7 additions & 7 deletions src/droptrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ int DropTrace::ringbuf_handler(void *ctx,
void *data,
[[maybe_unused]] size_t size) {
struct drop_data *d = static_cast<struct drop_data *>(data);
DropTrace *this_dt = static_cast<DropTrace *>(ctx);
this_dt->_drop_ts = d->tstamp;
DropTrace *this_dt = static_cast<DropTrace *>(ctx);
this_dt->_drop_ts = d->tstamp;

#ifdef ENABLE_DEBUG
// Print out debugging messages
Expand All @@ -59,13 +59,13 @@ int DropTrace::ringbuf_handler(void *ctx,
if (d->ip_proto == IPPROTO_TCP || d->ip_proto == IPPROTO_UDP) {
u16 sport = ntohs(d->transport.sport);
u16 dport = ntohs(d->transport.dport);
u32 seq = ntohl(d->transport.seq);
u32 ack = ntohl(d->transport.ack);
u32 seq = ntohl(d->transport.seq);
u32 ack = ntohl(d->transport.ack);
snprintf(buffer + nwrites, buffer_sz - nwrites,
", sport: %u, dport: %u, seq: %u, ack: %u", sport, dport,
seq, ack);
} else if (d->ip_proto == IPPROTO_ICMP) {
u16 echo_id = ntohs(d->icmp.icmp_echo_id);
u16 echo_id = ntohs(d->icmp.icmp_echo_id);
u16 echo_seq = ntohs(d->icmp.icmp_echo_seq);
snprintf(buffer + nwrites, buffer_sz - nwrites,
", icmp_type: %u, echo_id: %u, echo_seq: %u",
Expand Down Expand Up @@ -149,7 +149,7 @@ void DropTrace::start_listening_for(const Packet &pkt, Driver *driver) {
}

_target_pkt = pkt.to_drop_data(driver);
_drop_ts = 0;
_drop_ts = 0;

if (bpf_map__update_elem(_bpf->maps.target_packet, &_target_pkt_key,
sizeof(_target_pkt_key), &_target_pkt,
Expand Down Expand Up @@ -177,7 +177,7 @@ uint64_t DropTrace::get_drop_ts(chrono::microseconds timeout) {
int timeout_ms = (timeout.count() < 0)
? -1
: duration_cast<chrono::milliseconds>(timeout).count();
int res = ring_buffer__poll(_ringbuf, timeout_ms);
int res = ring_buffer__poll(_ringbuf, timeout_ms);

if (res < 0 && res != -EINTR) {
logger.error("ring_buffer__poll", errno);
Expand Down
6 changes: 3 additions & 3 deletions src/droptrace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class DropTrace : public DropDetection {

public:
// Disable the copy/move constructors and the assignment operators
DropTrace(const DropTrace &) = delete;
DropTrace(DropTrace &&) = delete;
DropTrace(const DropTrace &) = delete;
DropTrace(DropTrace &&) = delete;
DropTrace &operator=(const DropTrace &) = delete;
DropTrace &operator=(DropTrace &&) = delete;
DropTrace &operator=(DropTrace &&) = delete;
~DropTrace() override;

static DropTrace &get();
Expand Down
6 changes: 3 additions & 3 deletions src/ecrange.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class ECRange : public IPRange<IPv4Address> {
friend bool operator!=(const ECRange &, const ECRange &);

public:
ECRange() = delete;
ECRange() = delete;
ECRange(const ECRange &) = default;
ECRange(ECRange &&) = default;
ECRange(ECRange &&) = default;
ECRange(const IPv4Address &lb, const IPv4Address &ub);
ECRange(const IPNetwork<IPv4Address> &);
ECRange(const IPRange<IPv4Address> &);
Expand All @@ -37,7 +37,7 @@ class ECRange : public IPRange<IPv4Address> {
bool contains(const EqClass &) const;

ECRange &operator=(const ECRange &) = default;
ECRange &operator=(ECRange &&) = default;
ECRange &operator=(ECRange &&) = default;
};

bool operator<(const ECRange &, const ECRange &);
Expand Down
Loading

0 comments on commit 26e7228

Please sign in to comment.