Skip to content

Instantly share code, notes, and snippets.

@foamdino
Created April 24, 2025 08:00
Show Gist options
  • Select an option

  • Save foamdino/b71de99e0b1901721766a1d7f79414d4 to your computer and use it in GitHub Desktop.

Select an option

Save foamdino/b71de99e0b1901721766a1d7f79414d4 to your computer and use it in GitHub Desktop.
XSK startup core
for (channel_num = 0; channel_num < drone->wss->allocated_if->channels;
channel_num++)
{
/* Ensure our IRQ values are reset every iteration. */
irq_num = UINT32_MAX;
/* Ask Interface Manager for the IRQ mapping for this channel. */
res = drone_ifmgr_find_channel_irq(
teb, drone->wss->allocated_if, channel_num, &irq_num);
if (res != BL_OK)
{
bl_log_error_t(
teb,
"Failed to identify IRQ for interface %s channel %u: %s",
drone->wss->allocated_if->name,
channel_num,
bl_error_get_last_msg(teb));
break;
}
/* If we have a valid IRQ Number, lookup the core ID the IRQ should be
* mapped to. This will have been pre-calculated by System Manager.
* Otherwise, we use a core_id of UINT32_MAX to signal "no mapping." */
if (irq_num < UINT32_MAX)
irq_core_id = drone->aff_irq_cores[channel_num];
else
irq_core_id = UINT32_MAX;
ddos_debug_xsk_t(
teb,
"Interface %p channel %u mapped to irq 0x%X core_id 0x%X",
drone->wss->allocated_if,
channel_num,
irq_num,
irq_core_id);
/* We then get a new fingerprint instance from the FP subsystem. This is
* passed into (attached to) a new XSK instance as a data pointer, so it's
* accessible from the XSK instance thread. */
fp = ddos_fp_new_instance(teb, drone);
if (fp == NULL)
{
bl_log_error_t(teb,
"Failed to create FP instance for interface %s "
"channel %u: %s",
drone->wss->allocated_if->name,
channel_num,
bl_error_get_last_msg(teb));
break;
}
/* Now try create an XSK instance. */
xi = drone_xsk_instance_create(teb,
GlobalDdospXskContext,
drone->wss->allocated_if->name,
drone->wss->allocated_if->index,
channel_num,
irq_num,
irq_core_id,
drone->aff_packet_cores[channel_num],
drone->aff_packet_flags,
0,
fp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment