mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-22 01:20:39 +00:00
net: broadcast arp reply on arp protocol level
Instead of returning special value from forward() to broadcast arm reply call arp.learn() on all cpus at arp protocol lever. The ability of forward() to return special value will be removed by later patches.
This commit is contained in:
@@ -194,10 +194,6 @@ arp_for<L3>::learn(l2addr hwaddr, l3addr paddr) {
|
||||
template <typename L3>
|
||||
unsigned arp_for<L3>::forward(packet& p, size_t off)
|
||||
{
|
||||
auto ah = p.get_header<arp_hdr>(off);
|
||||
if (ntoh(ah->oper) == op_reply) {
|
||||
return std::numeric_limits<unsigned>::max(); // broadcast reply
|
||||
}
|
||||
return engine.cpu_id();
|
||||
}
|
||||
|
||||
@@ -216,7 +212,7 @@ arp_for<L3>::received(packet p) {
|
||||
case op_request:
|
||||
return handle_request(&h);
|
||||
case op_reply:
|
||||
learn(h.sender_hwaddr, h.sender_paddr);
|
||||
arp_learn(h.sender_hwaddr, h.sender_paddr);
|
||||
return make_ready_future<>();
|
||||
default:
|
||||
return make_ready_future<>();
|
||||
|
||||
@@ -249,6 +249,9 @@ public:
|
||||
void register_l4(proto_type id, ip_protocol* handler);
|
||||
net::hw_features hw_features() { 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);
|
||||
}
|
||||
};
|
||||
|
||||
template <ip_protocol_num ProtoNum>
|
||||
@@ -312,6 +315,8 @@ struct l4connid<InetTraits>::connid_hash : private std::hash<ipaddr>, private st
|
||||
}
|
||||
};
|
||||
|
||||
void arp_learn(ethernet_address l2, ipv4_address l3);
|
||||
|
||||
}
|
||||
|
||||
#endif /* IP_HH_ */
|
||||
|
||||
@@ -111,6 +111,9 @@ public:
|
||||
return ready_promise.get_future();
|
||||
}
|
||||
virtual bool has_per_core_namespace() override { return true; };
|
||||
void arp_learn(ethernet_address l2, ipv4_address l3) {
|
||||
_inet.learn(l2, l3);
|
||||
}
|
||||
friend class native_server_socket_impl<tcp4>;
|
||||
};
|
||||
|
||||
@@ -228,6 +231,16 @@ future<> native_network_stack::initialize() {
|
||||
});
|
||||
}
|
||||
|
||||
void arp_learn(ethernet_address l2, ipv4_address l3)
|
||||
{
|
||||
for (unsigned i = 0; i < smp::count; i++) {
|
||||
smp::submit_to(i, [l2, l3] {
|
||||
auto & ns = static_cast<native_network_stack&>(engine.net());
|
||||
ns.arp_learn(l2, l3);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void create_native_stack(boost::program_options::variables_map opts, std::shared_ptr<device> dev) {
|
||||
native_network_stack::ready_promise.set_value(std::unique_ptr<network_stack>(std::make_unique<native_network_stack>(opts, std::move(dev))));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user