This patch resets the AFPPacketVar linked to a Packet in the release
function to avoid any side effect when the packet is reused. To do
so a new AFPV_CLEANUP macro has been introduced.
}
if (AFPDerefSocket(p->afp_v.mpeer) == 0)
- return ret;
+ goto cleanup;
if (p->afp_v.relptr) {
union thdr h;
h.raw = p->afp_v.relptr;
h.h2->tp_status = TP_STATUS_KERNEL;
- return ret;
}
- return TM_ECODE_FAILED;
+
+cleanup:
+ AFPV_CLEANUP(&p->afp_v);
+ return ret;
}
/**
TAILQ_ENTRY(AFPPeer_) next;
} AFPPeer;
-/* per packet AF_PACKET vars */
+/**
+ * \brief per packet AF_PACKET vars
+ *
+ * This structure is used y the release data system and is cleaned
+ * up by the AFPV_CLEANUP macro below.
+ */
typedef struct AFPPacketVars_
{
void *relptr;
AFPPeer *mpeer;
} AFPPacketVars;
+#define AFPV_CLEANUP(afpv) do { \
+ (afpv)->relptr = NULL; \
+ (afpv)->copy_mode = 0; \
+ (afpv)->peer = NULL; \
+ (afpv)->mpeer = NULL; \
+} while(0)
+
/**
* @}
*/