diff options
author | Frank Pavlic <fpavlic@de.ibm.com> | 2005-11-10 07:51:25 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-11-11 08:26:22 -0500 |
commit | 6c951b9051f2094dd98bafcb46e7e6b3e8813231 (patch) | |
tree | 6625f15a30e4efc90a5ff24e8a7140fbb67732c9 /drivers/s390 | |
parent | e08d88cccbe0dfcfbaffb704d24e19803407935d (diff) |
[PATCH] s390: introduce guestLan sniffer support in qeth
[patch 6/7] s390: introduce guestLan sniffer support in qeth
From: Peter Tiedemann <ptiedem@de.ibm.com>
- introduce guestLan sniffer support in qeth
feature allows a linux in a virtual machine
guest to become a network LAN sniffer,
monitoring and recording the networking traffic
within an entire guestLan.
Signed-off-by: Frank Pavlic <fpavlic@de.ibm.com>
diffstat:
qeth.h | 2 +
qeth_main.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
qeth_mpc.h | 11 ++++---
3 files changed, 102 insertions(+), 4 deletions(-)
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'drivers/s390')
-rw-r--r-- | drivers/s390/net/qeth.h | 2 | ||||
-rw-r--r-- | drivers/s390/net/qeth_main.c | 93 | ||||
-rw-r--r-- | drivers/s390/net/qeth_mpc.h | 11 |
3 files changed, 102 insertions, 4 deletions
diff --git a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h index 44b9e14222a9..d238c7ed103b 100644 --- a/drivers/s390/net/qeth.h +++ b/drivers/s390/net/qeth.h | |||
@@ -750,6 +750,7 @@ struct qeth_card_info { | |||
750 | int unique_id; | 750 | int unique_id; |
751 | struct qeth_card_blkt blkt; | 751 | struct qeth_card_blkt blkt; |
752 | __u32 csum_mask; | 752 | __u32 csum_mask; |
753 | enum qeth_ipa_promisc_modes promisc_mode; | ||
753 | }; | 754 | }; |
754 | 755 | ||
755 | struct qeth_card_options { | 756 | struct qeth_card_options { |
@@ -776,6 +777,7 @@ struct qeth_card_options { | |||
776 | enum qeth_threads { | 777 | enum qeth_threads { |
777 | QETH_SET_IP_THREAD = 1, | 778 | QETH_SET_IP_THREAD = 1, |
778 | QETH_RECOVER_THREAD = 2, | 779 | QETH_RECOVER_THREAD = 2, |
780 | QETH_SET_PROMISC_MODE_THREAD = 4, | ||
779 | }; | 781 | }; |
780 | 782 | ||
781 | struct qeth_osn_info { | 783 | struct qeth_osn_info { |
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c index 0f7f5117f1cf..db07e465060b 100644 --- a/drivers/s390/net/qeth_main.c +++ b/drivers/s390/net/qeth_main.c | |||
@@ -160,6 +160,9 @@ static void | |||
160 | qeth_set_multicast_list(struct net_device *); | 160 | qeth_set_multicast_list(struct net_device *); |
161 | 161 | ||
162 | static void | 162 | static void |
163 | qeth_setadp_promisc_mode(struct qeth_card *); | ||
164 | |||
165 | static void | ||
163 | qeth_notify_processes(void) | 166 | qeth_notify_processes(void) |
164 | { | 167 | { |
165 | /*notify all registered processes */ | 168 | /*notify all registered processes */ |
@@ -965,6 +968,24 @@ qeth_register_ip_addresses(void *ptr) | |||
965 | return 0; | 968 | return 0; |
966 | } | 969 | } |
967 | 970 | ||
971 | /* | ||
972 | * Drive the SET_PROMISC_MODE thread | ||
973 | */ | ||
974 | static int | ||
975 | qeth_set_promisc_mode(void *ptr) | ||
976 | { | ||
977 | struct qeth_card *card = (struct qeth_card *) ptr; | ||
978 | |||
979 | daemonize("qeth_setprm"); | ||
980 | QETH_DBF_TEXT(trace,4,"setprm1"); | ||
981 | if (!qeth_do_run_thread(card, QETH_SET_PROMISC_MODE_THREAD)) | ||
982 | return 0; | ||
983 | QETH_DBF_TEXT(trace,4,"setprm2"); | ||
984 | qeth_setadp_promisc_mode(card); | ||
985 | qeth_clear_thread_running_bit(card, QETH_SET_PROMISC_MODE_THREAD); | ||
986 | return 0; | ||
987 | } | ||
988 | |||
968 | static int | 989 | static int |
969 | qeth_recover(void *ptr) | 990 | qeth_recover(void *ptr) |
970 | { | 991 | { |
@@ -1031,6 +1052,8 @@ qeth_start_kernel_thread(struct qeth_card *card) | |||
1031 | 1052 | ||
1032 | if (qeth_do_start_thread(card, QETH_SET_IP_THREAD)) | 1053 | if (qeth_do_start_thread(card, QETH_SET_IP_THREAD)) |
1033 | kernel_thread(qeth_register_ip_addresses, (void *)card,SIGCHLD); | 1054 | kernel_thread(qeth_register_ip_addresses, (void *)card,SIGCHLD); |
1055 | if (qeth_do_start_thread(card, QETH_SET_PROMISC_MODE_THREAD)) | ||
1056 | kernel_thread(qeth_set_promisc_mode, (void *)card, SIGCHLD); | ||
1034 | if (qeth_do_start_thread(card, QETH_RECOVER_THREAD)) | 1057 | if (qeth_do_start_thread(card, QETH_RECOVER_THREAD)) |
1035 | kernel_thread(qeth_recover, (void *) card, SIGCHLD); | 1058 | kernel_thread(qeth_recover, (void *) card, SIGCHLD); |
1036 | } | 1059 | } |
@@ -5003,6 +5026,10 @@ qeth_default_setassparms_cb(struct qeth_card *, struct qeth_reply *, | |||
5003 | unsigned long); | 5026 | unsigned long); |
5004 | 5027 | ||
5005 | static int | 5028 | static int |
5029 | qeth_default_setadapterparms_cb(struct qeth_card *card, | ||
5030 | struct qeth_reply *reply, | ||
5031 | unsigned long data); | ||
5032 | static int | ||
5006 | qeth_send_setassparms(struct qeth_card *, struct qeth_cmd_buffer *, | 5033 | qeth_send_setassparms(struct qeth_card *, struct qeth_cmd_buffer *, |
5007 | __u16, long, | 5034 | __u16, long, |
5008 | int (*reply_cb) | 5035 | int (*reply_cb) |
@@ -5476,6 +5503,59 @@ qeth_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) | |||
5476 | qeth_set_multicast_list(card->dev); | 5503 | qeth_set_multicast_list(card->dev); |
5477 | } | 5504 | } |
5478 | #endif | 5505 | #endif |
5506 | /** | ||
5507 | * Examine hardware response to SET_PROMISC_MODE | ||
5508 | */ | ||
5509 | static int | ||
5510 | qeth_setadp_promisc_mode_cb(struct qeth_card *card, | ||
5511 | struct qeth_reply *reply, | ||
5512 | unsigned long data) | ||
5513 | { | ||
5514 | struct qeth_ipa_cmd *cmd; | ||
5515 | struct qeth_ipacmd_setadpparms *setparms; | ||
5516 | |||
5517 | QETH_DBF_TEXT(trace,4,"prmadpcb"); | ||
5518 | |||
5519 | cmd = (struct qeth_ipa_cmd *) data; | ||
5520 | setparms = &(cmd->data.setadapterparms); | ||
5521 | |||
5522 | qeth_default_setadapterparms_cb(card, reply, (unsigned long)cmd); | ||
5523 | if (cmd->hdr.return_code) { | ||
5524 | QETH_DBF_TEXT_(trace,4,"prmrc%2.2x",cmd->hdr.return_code); | ||
5525 | setparms->data.mode = SET_PROMISC_MODE_OFF; | ||
5526 | } | ||
5527 | card->info.promisc_mode = setparms->data.mode; | ||
5528 | return 0; | ||
5529 | } | ||
5530 | /* | ||
5531 | * Set promiscuous mode (on or off) (SET_PROMISC_MODE command) | ||
5532 | */ | ||
5533 | static void | ||
5534 | qeth_setadp_promisc_mode(struct qeth_card *card) | ||
5535 | { | ||
5536 | enum qeth_ipa_promisc_modes mode; | ||
5537 | struct net_device *dev = card->dev; | ||
5538 | struct qeth_cmd_buffer *iob; | ||
5539 | struct qeth_ipa_cmd *cmd; | ||
5540 | |||
5541 | QETH_DBF_TEXT(trace, 4, "setprom"); | ||
5542 | |||
5543 | if (((dev->flags & IFF_PROMISC) && | ||
5544 | (card->info.promisc_mode == SET_PROMISC_MODE_ON)) || | ||
5545 | (!(dev->flags & IFF_PROMISC) && | ||
5546 | (card->info.promisc_mode == SET_PROMISC_MODE_OFF))) | ||
5547 | return; | ||
5548 | mode = SET_PROMISC_MODE_OFF; | ||
5549 | if (dev->flags & IFF_PROMISC) | ||
5550 | mode = SET_PROMISC_MODE_ON; | ||
5551 | QETH_DBF_TEXT_(trace, 4, "mode:%x", mode); | ||
5552 | |||
5553 | iob = qeth_get_adapter_cmd(card, IPA_SETADP_SET_PROMISC_MODE, | ||
5554 | sizeof(struct qeth_ipacmd_setadpparms)); | ||
5555 | cmd = (struct qeth_ipa_cmd *)(iob->data + IPA_PDU_HEADER_SIZE); | ||
5556 | cmd->data.setadapterparms.data.mode = mode; | ||
5557 | qeth_send_ipa_cmd(card, iob, qeth_setadp_promisc_mode_cb, NULL); | ||
5558 | } | ||
5479 | 5559 | ||
5480 | /** | 5560 | /** |
5481 | * set multicast address on card | 5561 | * set multicast address on card |
@@ -5501,6 +5581,11 @@ qeth_set_multicast_list(struct net_device *dev) | |||
5501 | out: | 5581 | out: |
5502 | if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0) | 5582 | if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0) |
5503 | schedule_work(&card->kernel_thread_starter); | 5583 | schedule_work(&card->kernel_thread_starter); |
5584 | if (!qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE)) | ||
5585 | return; | ||
5586 | if (qeth_set_thread_start_bit(card, QETH_SET_PROMISC_MODE_THREAD)==0) | ||
5587 | schedule_work(&card->kernel_thread_starter); | ||
5588 | |||
5504 | } | 5589 | } |
5505 | 5590 | ||
5506 | static int | 5591 | static int |
@@ -6510,6 +6595,8 @@ qeth_default_setadapterparms_cb(struct qeth_card *card, | |||
6510 | return 0; | 6595 | return 0; |
6511 | } | 6596 | } |
6512 | 6597 | ||
6598 | |||
6599 | |||
6513 | static int | 6600 | static int |
6514 | qeth_query_setadapterparms_cb(struct qeth_card *card, struct qeth_reply *reply, | 6601 | qeth_query_setadapterparms_cb(struct qeth_card *card, struct qeth_reply *reply, |
6515 | unsigned long data) | 6602 | unsigned long data) |
@@ -6676,6 +6763,12 @@ qeth_layer2_initialize(struct qeth_card *card) | |||
6676 | QETH_DBF_TEXT(setup, 2, "doL2init"); | 6763 | QETH_DBF_TEXT(setup, 2, "doL2init"); |
6677 | QETH_DBF_TEXT_(setup, 2, "doL2%s", CARD_BUS_ID(card)); | 6764 | QETH_DBF_TEXT_(setup, 2, "doL2%s", CARD_BUS_ID(card)); |
6678 | 6765 | ||
6766 | rc = qeth_query_setadapterparms(card); | ||
6767 | if (rc) { | ||
6768 | PRINT_WARN("could not query adapter parameters on device %s: " | ||
6769 | "x%x\n", CARD_BUS_ID(card), rc); | ||
6770 | } | ||
6771 | |||
6679 | rc = qeth_setadpparms_change_macaddr(card); | 6772 | rc = qeth_setadpparms_change_macaddr(card); |
6680 | if (rc) { | 6773 | if (rc) { |
6681 | PRINT_WARN("couldn't get MAC address on " | 6774 | PRINT_WARN("couldn't get MAC address on " |
diff --git a/drivers/s390/net/qeth_mpc.h b/drivers/s390/net/qeth_mpc.h index 7edc5f1fc0d2..628c9f56a43b 100644 --- a/drivers/s390/net/qeth_mpc.h +++ b/drivers/s390/net/qeth_mpc.h | |||
@@ -14,7 +14,7 @@ | |||
14 | 14 | ||
15 | #include <asm/qeth.h> | 15 | #include <asm/qeth.h> |
16 | 16 | ||
17 | #define VERSION_QETH_MPC_H "$Revision: 1.43 $" | 17 | #define VERSION_QETH_MPC_H "$Revision: 1.44 $" |
18 | 18 | ||
19 | extern const char *VERSION_QETH_MPC_C; | 19 | extern const char *VERSION_QETH_MPC_C; |
20 | 20 | ||
@@ -217,7 +217,7 @@ enum qeth_ipa_setadp_cmd { | |||
217 | IPA_SETADP_SEND_OSA_MESSAGE = 0x0100, | 217 | IPA_SETADP_SEND_OSA_MESSAGE = 0x0100, |
218 | IPA_SETADP_SET_SNMP_CONTROL = 0x0200, | 218 | IPA_SETADP_SET_SNMP_CONTROL = 0x0200, |
219 | IPA_SETADP_READ_SNMP_PARMS = 0x0400, | 219 | IPA_SETADP_READ_SNMP_PARMS = 0x0400, |
220 | IPA_SETADP_WRITE_SNMP_PARMS = 0x0800, | 220 | IPA_SETADP_SET_PROMISC_MODE = 0x0800, |
221 | IPA_SETADP_QUERY_CARD_INFO = 0x1000, | 221 | IPA_SETADP_QUERY_CARD_INFO = 0x1000, |
222 | }; | 222 | }; |
223 | enum qeth_ipa_mac_ops { | 223 | enum qeth_ipa_mac_ops { |
@@ -232,9 +232,12 @@ enum qeth_ipa_addr_ops { | |||
232 | CHANGE_ADDR_ADD_ADDR = 1, | 232 | CHANGE_ADDR_ADD_ADDR = 1, |
233 | CHANGE_ADDR_DEL_ADDR = 2, | 233 | CHANGE_ADDR_DEL_ADDR = 2, |
234 | CHANGE_ADDR_FLUSH_ADDR_TABLE = 4, | 234 | CHANGE_ADDR_FLUSH_ADDR_TABLE = 4, |
235 | |||
236 | |||
237 | }; | 235 | }; |
236 | enum qeth_ipa_promisc_modes { | ||
237 | SET_PROMISC_MODE_OFF = 0, | ||
238 | SET_PROMISC_MODE_ON = 1, | ||
239 | }; | ||
240 | |||
238 | /* (SET)DELIP(M) IPA stuff ***************************************************/ | 241 | /* (SET)DELIP(M) IPA stuff ***************************************************/ |
239 | struct qeth_ipacmd_setdelip4 { | 242 | struct qeth_ipacmd_setdelip4 { |
240 | __u8 ip_addr[4]; | 243 | __u8 ip_addr[4]; |