net: return reference to hw_feature instead of copying the structure

I noticed that tcp::hw_features() is not inlined and copies the
structure to a caller. The function takes ~1.5% in httpd profiling.
This commit is contained in:
Gleb Natapov
2015-02-19 09:53:55 +02:00
committed by Avi Kivity
parent 7f8d88371a
commit bebefe2afe
3 changed files with 3 additions and 3 deletions

View File

@@ -368,7 +368,7 @@ public:
tcp<ipv4_traits>& get_tcp() { return *_tcp._tcp; }
ipv4_udp& get_udp() { return _udp; }
void register_l4(proto_type id, ip_protocol* handler);
net::hw_features hw_features() { return _netif->hw_features(); }
const net::hw_features& hw_features() const { return _netif->hw_features(); }
static bool needs_frag(packet& p, ip_protocol_num proto_num, net::hw_features hw_features);
void learn(ethernet_address l2, ipv4_address l3) {
_arp.learn(l2, l3);

View File

@@ -119,7 +119,7 @@ private:
public:
explicit interface(std::shared_ptr<device> dev);
ethernet_address hw_address() { return _hw_address; }
net::hw_features hw_features() { return _hw_features; }
const net::hw_features& hw_features() const { return _hw_features; }
subscription<packet, ethernet_address> register_l3(eth_protocol_num proto_num,
std::function<future<> (packet p, ethernet_address from)> next,
std::function<bool (forward_hash&, packet&, size_t)> forward);

View File

@@ -591,7 +591,7 @@ public:
bool forward(forward_hash& out_hash_data, packet& p, size_t off);
listener listen(uint16_t port, size_t queue_length = 100);
future<connection> connect(socket_address sa);
net::hw_features hw_features() { return _inet._inet.hw_features(); }
const net::hw_features& hw_features() const { return _inet._inet.hw_features(); }
future<> poll_tcb(ipaddr to, lw_shared_ptr<tcb> tcb);
private:
void send_packet_without_tcb(ipaddr from, ipaddr to, packet p);