|
26 | 26 | #include <linux/bitops.h>
|
27 | 27 | #include <linux/slab.h>
|
28 | 28 | #include <linux/module.h>
|
| 29 | +#include <net/drop_monitor.h> |
29 | 30 | #include <net/genetlink.h>
|
30 | 31 | #include <net/netevent.h>
|
31 | 32 |
|
|
43 | 44 | * netlink alerts
|
44 | 45 | */
|
45 | 46 | static int trace_state = TRACE_OFF;
|
| 47 | +static bool monitor_hw; |
46 | 48 |
|
47 | 49 | /* net_dm_mutex
|
48 | 50 | *
|
@@ -93,6 +95,8 @@ struct net_dm_alert_ops {
|
93 | 95 | void (*napi_poll_probe)(void *ignore, struct napi_struct *napi,
|
94 | 96 | int work, int budget);
|
95 | 97 | void (*work_item_func)(struct work_struct *work);
|
| 98 | + void (*hw_probe)(struct sk_buff *skb, |
| 99 | + const struct net_dm_hw_metadata *hw_metadata); |
96 | 100 | };
|
97 | 101 |
|
98 | 102 | struct net_dm_skb_cb {
|
@@ -267,10 +271,17 @@ static void trace_napi_poll_hit(void *ignore, struct napi_struct *napi,
|
267 | 271 | rcu_read_unlock();
|
268 | 272 | }
|
269 | 273 |
|
| 274 | +static void |
| 275 | +net_dm_hw_summary_probe(struct sk_buff *skb, |
| 276 | + const struct net_dm_hw_metadata *hw_metadata) |
| 277 | +{ |
| 278 | +} |
| 279 | + |
270 | 280 | static const struct net_dm_alert_ops net_dm_alert_summary_ops = {
|
271 | 281 | .kfree_skb_probe = trace_kfree_skb_hit,
|
272 | 282 | .napi_poll_probe = trace_napi_poll_hit,
|
273 | 283 | .work_item_func = send_dm_alert,
|
| 284 | + .hw_probe = net_dm_hw_summary_probe, |
274 | 285 | };
|
275 | 286 |
|
276 | 287 | static void net_dm_packet_trace_kfree_skb_hit(void *ignore,
|
@@ -482,17 +493,34 @@ static void net_dm_packet_work(struct work_struct *work)
|
482 | 493 | net_dm_packet_report(skb);
|
483 | 494 | }
|
484 | 495 |
|
| 496 | +static void |
| 497 | +net_dm_hw_packet_probe(struct sk_buff *skb, |
| 498 | + const struct net_dm_hw_metadata *hw_metadata) |
| 499 | +{ |
| 500 | +} |
| 501 | + |
485 | 502 | static const struct net_dm_alert_ops net_dm_alert_packet_ops = {
|
486 | 503 | .kfree_skb_probe = net_dm_packet_trace_kfree_skb_hit,
|
487 | 504 | .napi_poll_probe = net_dm_packet_trace_napi_poll_hit,
|
488 | 505 | .work_item_func = net_dm_packet_work,
|
| 506 | + .hw_probe = net_dm_hw_packet_probe, |
489 | 507 | };
|
490 | 508 |
|
491 | 509 | static const struct net_dm_alert_ops *net_dm_alert_ops_arr[] = {
|
492 | 510 | [NET_DM_ALERT_MODE_SUMMARY] = &net_dm_alert_summary_ops,
|
493 | 511 | [NET_DM_ALERT_MODE_PACKET] = &net_dm_alert_packet_ops,
|
494 | 512 | };
|
495 | 513 |
|
| 514 | +void net_dm_hw_report(struct sk_buff *skb, |
| 515 | + const struct net_dm_hw_metadata *hw_metadata) |
| 516 | +{ |
| 517 | + if (!monitor_hw) |
| 518 | + return; |
| 519 | + |
| 520 | + net_dm_alert_ops_arr[net_dm_alert_mode]->hw_probe(skb, hw_metadata); |
| 521 | +} |
| 522 | +EXPORT_SYMBOL_GPL(net_dm_hw_report); |
| 523 | + |
496 | 524 | static int net_dm_trace_on_set(struct netlink_ext_ack *extack)
|
497 | 525 | {
|
498 | 526 | const struct net_dm_alert_ops *ops;
|
|
0 commit comments