Skip to content

Commit 6f107c7

Browse files
0x7f454c46davem330
authored andcommitted
pktgen: Add behaviour flags macro to generate flags/names
PKT_FALGS macro will be used to add package behavior names definitions to simplify the code that prints/reads pkg flags. Sorted the array in order of printing the flags in pktgen_if_show() Note: Renamed IPSEC_ON => IPSEC for simplicity. No visible behavior change expected. Signed-off-by: Dmitry Safonov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 57a5749 commit 6f107c7

File tree

1 file changed

+34
-23
lines changed

1 file changed

+34
-23
lines changed

net/core/pktgen.c

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -184,25 +184,36 @@
184184

185185
#define func_enter() pr_debug("entering %s\n", __func__);
186186

187+
#define PKT_FLAGS \
188+
pf(IPV6) /* Interface in IPV6 Mode */ \
189+
pf(IPSRC_RND) /* IP-Src Random */ \
190+
pf(IPDST_RND) /* IP-Dst Random */ \
191+
pf(TXSIZE_RND) /* Transmit size is random */ \
192+
pf(UDPSRC_RND) /* UDP-Src Random */ \
193+
pf(UDPDST_RND) /* UDP-Dst Random */ \
194+
pf(UDPCSUM) /* Include UDP checksum */ \
195+
pf(NO_TIMESTAMP) /* Don't timestamp packets (default TS) */ \
196+
pf(MPLS_RND) /* Random MPLS labels */ \
197+
pf(QUEUE_MAP_RND) /* queue map Random */ \
198+
pf(QUEUE_MAP_CPU) /* queue map mirrors smp_processor_id() */ \
199+
pf(FLOW_SEQ) /* Sequential flows */ \
200+
pf(IPSEC) /* ipsec on for flows */ \
201+
pf(MACSRC_RND) /* MAC-Src Random */ \
202+
pf(MACDST_RND) /* MAC-Dst Random */ \
203+
pf(VID_RND) /* Random VLAN ID */ \
204+
pf(SVID_RND) /* Random SVLAN ID */ \
205+
pf(NODE) /* Node memory alloc*/ \
206+
207+
#define pf(flag) flag##_SHIFT,
208+
enum pkt_flags {
209+
PKT_FLAGS
210+
};
211+
#undef pf
212+
187213
/* Device flag bits */
188-
#define F_IPSRC_RND (1<<0) /* IP-Src Random */
189-
#define F_IPDST_RND (1<<1) /* IP-Dst Random */
190-
#define F_UDPSRC_RND (1<<2) /* UDP-Src Random */
191-
#define F_UDPDST_RND (1<<3) /* UDP-Dst Random */
192-
#define F_MACSRC_RND (1<<4) /* MAC-Src Random */
193-
#define F_MACDST_RND (1<<5) /* MAC-Dst Random */
194-
#define F_TXSIZE_RND (1<<6) /* Transmit size is random */
195-
#define F_IPV6 (1<<7) /* Interface in IPV6 Mode */
196-
#define F_MPLS_RND (1<<8) /* Random MPLS labels */
197-
#define F_VID_RND (1<<9) /* Random VLAN ID */
198-
#define F_SVID_RND (1<<10) /* Random SVLAN ID */
199-
#define F_FLOW_SEQ (1<<11) /* Sequential flows */
200-
#define F_IPSEC_ON (1<<12) /* ipsec on for flows */
201-
#define F_QUEUE_MAP_RND (1<<13) /* queue map Random */
202-
#define F_QUEUE_MAP_CPU (1<<14) /* queue map mirrors smp_processor_id() */
203-
#define F_NODE (1<<15) /* Node memory alloc*/
204-
#define F_UDPCSUM (1<<16) /* Include UDP checksum */
205-
#define F_NO_TIMESTAMP (1<<17) /* Don't timestamp packets (default TS) */
214+
#define pf(flag) static const __u32 F_##flag = (1<<flag##_SHIFT);
215+
PKT_FLAGS
216+
#undef pf
206217

207218
/* Thread control flag bits */
208219
#define T_STOP (1<<0) /* Stop run */
@@ -672,7 +683,7 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
672683
}
673684

674685
#ifdef CONFIG_XFRM
675-
if (pkt_dev->flags & F_IPSEC_ON) {
686+
if (pkt_dev->flags & F_IPSEC) {
676687
seq_puts(seq, "IPSEC ");
677688
if (pkt_dev->spi)
678689
seq_printf(seq, "spi:%u", pkt_dev->spi);
@@ -1303,10 +1314,10 @@ static ssize_t pktgen_if_write(struct file *file,
13031314
pkt_dev->flags &= ~F_QUEUE_MAP_CPU;
13041315
#ifdef CONFIG_XFRM
13051316
else if (strcmp(f, "IPSEC") == 0)
1306-
pkt_dev->flags |= F_IPSEC_ON;
1317+
pkt_dev->flags |= F_IPSEC;
13071318

13081319
else if (strcmp(f, "!IPSEC") == 0)
1309-
pkt_dev->flags &= ~F_IPSEC_ON;
1320+
pkt_dev->flags &= ~F_IPSEC;
13101321
#endif
13111322

13121323
else if (strcmp(f, "!IPV6") == 0)
@@ -2547,7 +2558,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
25472558
pkt_dev->flows[flow].cur_daddr =
25482559
pkt_dev->cur_daddr;
25492560
#ifdef CONFIG_XFRM
2550-
if (pkt_dev->flags & F_IPSEC_ON)
2561+
if (pkt_dev->flags & F_IPSEC)
25512562
get_ipsec_sa(pkt_dev, flow);
25522563
#endif
25532564
pkt_dev->nflows++;
@@ -2652,7 +2663,7 @@ static void free_SAs(struct pktgen_dev *pkt_dev)
26522663
static int process_ipsec(struct pktgen_dev *pkt_dev,
26532664
struct sk_buff *skb, __be16 protocol)
26542665
{
2655-
if (pkt_dev->flags & F_IPSEC_ON) {
2666+
if (pkt_dev->flags & F_IPSEC) {
26562667
struct xfrm_state *x = pkt_dev->flows[pkt_dev->curfl].x;
26572668
int nhead = 0;
26582669
if (x) {

0 commit comments

Comments
 (0)