aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-04-02 23:53:45 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-02 23:53:45 -0400
commitcd6362befe4cc7bf589a5236d2a780af2d47bcc9 (patch)
tree3bd4e13ec3f92a00dc4f6c3d65e820b54dbfe46e /tools
parent0f1b1e6d73cb989ce2c071edc57deade3b084dfe (diff)
parentb1586f099ba897542ece36e8a23c1a62907261ef (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking updates from David Miller: "Here is my initial pull request for the networking subsystem during this merge window: 1) Support for ESN in AH (RFC 4302) from Fan Du. 2) Add full kernel doc for ethtool command structures, from Ben Hutchings. 3) Add BCM7xxx PHY driver, from Florian Fainelli. 4) Export computed TCP rate information in netlink socket dumps, from Eric Dumazet. 5) Allow IPSEC SA to be dumped partially using a filter, from Nicolas Dichtel. 6) Convert many drivers to pci_enable_msix_range(), from Alexander Gordeev. 7) Record SKB timestamps more efficiently, from Eric Dumazet. 8) Switch to microsecond resolution for TCP round trip times, also from Eric Dumazet. 9) Clean up and fix 6lowpan fragmentation handling by making use of the existing inet_frag api for it's implementation. 10) Add TX grant mapping to xen-netback driver, from Zoltan Kiss. 11) Auto size SKB lengths when composing netlink messages based upon past message sizes used, from Eric Dumazet. 12) qdisc dumps can take a long time, add a cond_resched(), From Eric Dumazet. 13) Sanitize netpoll core and drivers wrt. SKB handling semantics. Get rid of never-used-in-tree netpoll RX handling. From Eric W Biederman. 14) Support inter-address-family and namespace changing in VTI tunnel driver(s). From Steffen Klassert. 15) Add Altera TSE driver, from Vince Bridgers. 16) Optimizing csum_replace2() so that it doesn't adjust the checksum by checksumming the entire header, from Eric Dumazet. 17) Expand BPF internal implementation for faster interpreting, more direct translations into JIT'd code, and much cleaner uses of BPF filtering in non-socket ocntexts. From Daniel Borkmann and Alexei Starovoitov" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1976 commits) netpoll: Use skb_irq_freeable to make zap_completion_queue safe. net: Add a test to see if a skb is freeable in irq context qlcnic: Fix build failure due to undefined reference to `vxlan_get_rx_port' net: ptp: move PTP classifier in its own file net: sxgbe: make "core_ops" static net: sxgbe: fix logical vs bitwise operation net: sxgbe: sxgbe_mdio_register() frees the bus Call efx_set_channels() before efx->type->dimension_resources() xen-netback: disable rogue vif in kthread context net/mlx4: Set proper build dependancy with vxlan be2net: fix build dependency on VxLAN mac802154: make csma/cca parameters per-wpan mac802154: allow only one WPAN to be up at any given time net: filter: minor: fix kdoc in __sk_run_filter netlink: don't compare the nul-termination in nla_strcmp can: c_can: Avoid led toggling for every packet. can: c_can: Simplify TX interrupt cleanup can: c_can: Store dlc private can: c_can: Reduce register access can: c_can: Make the code readable ...
Diffstat (limited to 'tools')
-rw-r--r--tools/net/bpf_dbg.c119
1 files changed, 55 insertions, 64 deletions
diff --git a/tools/net/bpf_dbg.c b/tools/net/bpf_dbg.c
index 65dc757f7f7b..bb31813e43dd 100644
--- a/tools/net/bpf_dbg.c
+++ b/tools/net/bpf_dbg.c
@@ -87,9 +87,6 @@
87 __attribute__ ((format (printf, (pos_fmtstr), (pos_fmtargs)))) 87 __attribute__ ((format (printf, (pos_fmtstr), (pos_fmtargs))))
88#endif 88#endif
89 89
90#define CMD(_name, _func) { .name = _name, .func = _func, }
91#define OP(_op, _name) [_op] = _name
92
93enum { 90enum {
94 CMD_OK, 91 CMD_OK,
95 CMD_ERR, 92 CMD_ERR,
@@ -145,32 +142,32 @@ static size_t pcap_map_size = 0;
145static char *pcap_ptr_va_start, *pcap_ptr_va_curr; 142static char *pcap_ptr_va_start, *pcap_ptr_va_curr;
146 143
147static const char * const op_table[] = { 144static const char * const op_table[] = {
148 OP(BPF_ST, "st"), 145 [BPF_ST] = "st",
149 OP(BPF_STX, "stx"), 146 [BPF_STX] = "stx",
150 OP(BPF_LD_B, "ldb"), 147 [BPF_LD_B] = "ldb",
151 OP(BPF_LD_H, "ldh"), 148 [BPF_LD_H] = "ldh",
152 OP(BPF_LD_W, "ld"), 149 [BPF_LD_W] = "ld",
153 OP(BPF_LDX, "ldx"), 150 [BPF_LDX] = "ldx",
154 OP(BPF_LDX_B, "ldxb"), 151 [BPF_LDX_B] = "ldxb",
155 OP(BPF_JMP_JA, "ja"), 152 [BPF_JMP_JA] = "ja",
156 OP(BPF_JMP_JEQ, "jeq"), 153 [BPF_JMP_JEQ] = "jeq",
157 OP(BPF_JMP_JGT, "jgt"), 154 [BPF_JMP_JGT] = "jgt",
158 OP(BPF_JMP_JGE, "jge"), 155 [BPF_JMP_JGE] = "jge",
159 OP(BPF_JMP_JSET, "jset"), 156 [BPF_JMP_JSET] = "jset",
160 OP(BPF_ALU_ADD, "add"), 157 [BPF_ALU_ADD] = "add",
161 OP(BPF_ALU_SUB, "sub"), 158 [BPF_ALU_SUB] = "sub",
162 OP(BPF_ALU_MUL, "mul"), 159 [BPF_ALU_MUL] = "mul",
163 OP(BPF_ALU_DIV, "div"), 160 [BPF_ALU_DIV] = "div",
164 OP(BPF_ALU_MOD, "mod"), 161 [BPF_ALU_MOD] = "mod",
165 OP(BPF_ALU_NEG, "neg"), 162 [BPF_ALU_NEG] = "neg",
166 OP(BPF_ALU_AND, "and"), 163 [BPF_ALU_AND] = "and",
167 OP(BPF_ALU_OR, "or"), 164 [BPF_ALU_OR] = "or",
168 OP(BPF_ALU_XOR, "xor"), 165 [BPF_ALU_XOR] = "xor",
169 OP(BPF_ALU_LSH, "lsh"), 166 [BPF_ALU_LSH] = "lsh",
170 OP(BPF_ALU_RSH, "rsh"), 167 [BPF_ALU_RSH] = "rsh",
171 OP(BPF_MISC_TAX, "tax"), 168 [BPF_MISC_TAX] = "tax",
172 OP(BPF_MISC_TXA, "txa"), 169 [BPF_MISC_TXA] = "txa",
173 OP(BPF_RET, "ret"), 170 [BPF_RET] = "ret",
174}; 171};
175 172
176static __check_format_printf(1, 2) int rl_printf(const char *fmt, ...) 173static __check_format_printf(1, 2) int rl_printf(const char *fmt, ...)
@@ -1127,7 +1124,6 @@ static int cmd_step(char *num)
1127static int cmd_select(char *num) 1124static int cmd_select(char *num)
1128{ 1125{
1129 unsigned int which, i; 1126 unsigned int which, i;
1130 struct pcap_pkthdr *hdr;
1131 bool have_next = true; 1127 bool have_next = true;
1132 1128
1133 if (!pcap_loaded() || strlen(num) == 0) 1129 if (!pcap_loaded() || strlen(num) == 0)
@@ -1144,7 +1140,7 @@ static int cmd_select(char *num)
1144 1140
1145 for (i = 0; i < which && (have_next = pcap_next_pkt()); i++) 1141 for (i = 0; i < which && (have_next = pcap_next_pkt()); i++)
1146 /* noop */; 1142 /* noop */;
1147 if (!have_next || (hdr = pcap_curr_pkt()) == NULL) { 1143 if (!have_next || pcap_curr_pkt() == NULL) {
1148 rl_printf("no packet #%u available!\n", which); 1144 rl_printf("no packet #%u available!\n", which);
1149 pcap_reset_pkt(); 1145 pcap_reset_pkt();
1150 return CMD_ERR; 1146 return CMD_ERR;
@@ -1177,9 +1173,8 @@ static int cmd_breakpoint(char *subcmd)
1177static int cmd_run(char *num) 1173static int cmd_run(char *num)
1178{ 1174{
1179 static uint32_t pass = 0, fail = 0; 1175 static uint32_t pass = 0, fail = 0;
1180 struct pcap_pkthdr *hdr;
1181 bool has_limit = true; 1176 bool has_limit = true;
1182 int ret, pkts = 0, i = 0; 1177 int pkts = 0, i = 0;
1183 1178
1184 if (!bpf_prog_loaded() || !pcap_loaded()) 1179 if (!bpf_prog_loaded() || !pcap_loaded())
1185 return CMD_ERR; 1180 return CMD_ERR;
@@ -1189,10 +1184,10 @@ static int cmd_run(char *num)
1189 has_limit = false; 1184 has_limit = false;
1190 1185
1191 do { 1186 do {
1192 hdr = pcap_curr_pkt(); 1187 struct pcap_pkthdr *hdr = pcap_curr_pkt();
1193 ret = bpf_run_all(bpf_image, bpf_prog_len, 1188 int ret = bpf_run_all(bpf_image, bpf_prog_len,
1194 (uint8_t *) hdr + sizeof(*hdr), 1189 (uint8_t *) hdr + sizeof(*hdr),
1195 hdr->caplen, hdr->len); 1190 hdr->caplen, hdr->len);
1196 if (ret > 0) 1191 if (ret > 0)
1197 pass++; 1192 pass++;
1198 else if (ret == 0) 1193 else if (ret == 0)
@@ -1245,14 +1240,14 @@ static int cmd_quit(char *dontcare)
1245} 1240}
1246 1241
1247static const struct shell_cmd cmds[] = { 1242static const struct shell_cmd cmds[] = {
1248 CMD("load", cmd_load), 1243 { .name = "load", .func = cmd_load },
1249 CMD("select", cmd_select), 1244 { .name = "select", .func = cmd_select },
1250 CMD("step", cmd_step), 1245 { .name = "step", .func = cmd_step },
1251 CMD("run", cmd_run), 1246 { .name = "run", .func = cmd_run },
1252 CMD("breakpoint", cmd_breakpoint), 1247 { .name = "breakpoint", .func = cmd_breakpoint },
1253 CMD("disassemble", cmd_disassemble), 1248 { .name = "disassemble", .func = cmd_disassemble },
1254 CMD("dump", cmd_dump), 1249 { .name = "dump", .func = cmd_dump },
1255 CMD("quit", cmd_quit), 1250 { .name = "quit", .func = cmd_quit },
1256}; 1251};
1257 1252
1258static int execf(char *arg) 1253static int execf(char *arg)
@@ -1280,7 +1275,6 @@ out:
1280static char *shell_comp_gen(const char *buf, int state) 1275static char *shell_comp_gen(const char *buf, int state)
1281{ 1276{
1282 static int list_index, len; 1277 static int list_index, len;
1283 const char *name;
1284 1278
1285 if (!state) { 1279 if (!state) {
1286 list_index = 0; 1280 list_index = 0;
@@ -1288,9 +1282,9 @@ static char *shell_comp_gen(const char *buf, int state)
1288 } 1282 }
1289 1283
1290 for (; list_index < array_size(cmds); ) { 1284 for (; list_index < array_size(cmds); ) {
1291 name = cmds[list_index].name; 1285 const char *name = cmds[list_index].name;
1292 list_index++;
1293 1286
1287 list_index++;
1294 if (strncmp(name, buf, len) == 0) 1288 if (strncmp(name, buf, len) == 0)
1295 return strdup(name); 1289 return strdup(name);
1296 } 1290 }
@@ -1322,16 +1316,9 @@ static void init_shell(FILE *fin, FILE *fout)
1322{ 1316{
1323 char file[128]; 1317 char file[128];
1324 1318
1325 memset(file, 0, sizeof(file)); 1319 snprintf(file, sizeof(file), "%s/.bpf_dbg_history", getenv("HOME"));
1326 snprintf(file, sizeof(file) - 1,
1327 "%s/.bpf_dbg_history", getenv("HOME"));
1328
1329 read_history(file); 1320 read_history(file);
1330 1321
1331 memset(file, 0, sizeof(file));
1332 snprintf(file, sizeof(file) - 1,
1333 "%s/.bpf_dbg_init", getenv("HOME"));
1334
1335 rl_instream = fin; 1322 rl_instream = fin;
1336 rl_outstream = fout; 1323 rl_outstream = fout;
1337 1324
@@ -1348,37 +1335,41 @@ static void init_shell(FILE *fin, FILE *fout)
1348 rl_bind_key_in_map('\t', rl_complete, emacs_meta_keymap); 1335 rl_bind_key_in_map('\t', rl_complete, emacs_meta_keymap);
1349 rl_bind_key_in_map('\033', rl_complete, emacs_meta_keymap); 1336 rl_bind_key_in_map('\033', rl_complete, emacs_meta_keymap);
1350 1337
1338 snprintf(file, sizeof(file), "%s/.bpf_dbg_init", getenv("HOME"));
1351 rl_read_init_file(file); 1339 rl_read_init_file(file);
1340
1352 rl_prep_terminal(0); 1341 rl_prep_terminal(0);
1353 rl_set_signals(); 1342 rl_set_signals();
1354 1343
1355 signal(SIGINT, intr_shell); 1344 signal(SIGINT, intr_shell);
1356} 1345}
1357 1346
1358static void exit_shell(void) 1347static void exit_shell(FILE *fin, FILE *fout)
1359{ 1348{
1360 char file[128]; 1349 char file[128];
1361 1350
1362 memset(file, 0, sizeof(file)); 1351 snprintf(file, sizeof(file), "%s/.bpf_dbg_history", getenv("HOME"));
1363 snprintf(file, sizeof(file) - 1,
1364 "%s/.bpf_dbg_history", getenv("HOME"));
1365
1366 write_history(file); 1352 write_history(file);
1353
1367 clear_history(); 1354 clear_history();
1368 rl_deprep_terminal(); 1355 rl_deprep_terminal();
1369 1356
1370 try_close_pcap(); 1357 try_close_pcap();
1358
1359 if (fin != stdin)
1360 fclose(fin);
1361 if (fout != stdout)
1362 fclose(fout);
1371} 1363}
1372 1364
1373static int run_shell_loop(FILE *fin, FILE *fout) 1365static int run_shell_loop(FILE *fin, FILE *fout)
1374{ 1366{
1375 char *buf; 1367 char *buf;
1376 int ret;
1377 1368
1378 init_shell(fin, fout); 1369 init_shell(fin, fout);
1379 1370
1380 while ((buf = readline("> ")) != NULL) { 1371 while ((buf = readline("> ")) != NULL) {
1381 ret = execf(buf); 1372 int ret = execf(buf);
1382 if (ret == CMD_EX) 1373 if (ret == CMD_EX)
1383 break; 1374 break;
1384 if (ret == CMD_OK && strlen(buf) > 0) 1375 if (ret == CMD_OK && strlen(buf) > 0)
@@ -1387,7 +1378,7 @@ static int run_shell_loop(FILE *fin, FILE *fout)
1387 free(buf); 1378 free(buf);
1388 } 1379 }
1389 1380
1390 exit_shell(); 1381 exit_shell(fin, fout);
1391 return 0; 1382 return 0;
1392} 1383}
1393 1384