/* * netsniff-ng - the packet sniffing beast * Copyright 2009, 2010 Daniel Borkmann. * Subject to the GPL, version 2. */ #include #include #include #include #include "proto.h" #include "protos.h" #include "dissector_eth.h" #include "pkt_buff.h" #include "oui.h" static void ethernet(struct pkt_buff *pkt) { char *type; uint8_t *src_mac, *dst_mac; struct ethhdr *eth = (struct ethhdr *) pkt_pull(pkt, sizeof(*eth)); if (eth == NULL) return; src_mac = eth->h_source; dst_mac = eth->h_dest; tprintf(" [ Eth "); tprintf("MAC (%.2x:%.2x:%.2x:%.2x:%.2x:%.2x => ", src_mac[0], src_mac[1], src_mac[2], src_mac[3], src_mac[4], src_mac[5]); tprintf("%.2x:%.2x:%.2x:%.2x:%.2x:%.2x), ", dst_mac[0], dst_mac[1], dst_mac[2], dst_mac[3], dst_mac[4], dst_mac[5]); tprintf("Proto (0x%.4x", ntohs(eth->h_proto)); type = lookup_ether_type(ntohs(eth->h_proto)); if (type) tprintf(", %s%s%s", colorize_start(bold), type, colorize_end()); tprintf(") ]\n"); tprintf(" [ Vendor "); tprintf("(%s => %s)", lookup_vendor_str((src_mac[0] << 16) | (src_mac[1] << 8) | src_mac[2]), lookup_vendor_str((dst_mac[0] << 16) | (dst_mac[1] << 8) | dst_mac[2])); tprintf(" ]\n"); pkt_set_proto(pkt, ð_lay2, ntohs(eth->h_proto)); } static void ethernet_less(struct pkt_buff *pkt) { uint8_t *src_mac, *dst_mac; struct ethhdr *eth = (struct ethhdr *) pkt_pull(pkt, sizeof(*eth)); if (eth == NULL) return; src_mac = eth->h_source; dst_mac = eth->h_dest; tprintf(" %s => %s ", lookup_vendor_str((src_mac[0] << 16) | (src_mac[1] << 8) | src_mac[2]), lookup_vendor_str((dst_mac[0] << 16) | (dst_mac[1] << 8) | dst_mac[2])); tprintf("%s%s%s", colorize_start(bold), lookup_ether_type(ntohs(eth->h_proto)), colorize_end()); pkt_set_proto(pkt, ð_lay2, ntohs(eth->h_proto)); } struct protocol ethernet_ops = { .key = 0, .print_full = ethernet, .print_less = ethernet_less, }; f
diff options
context:
space:
mode:
authorDaniel Mentz <danielmentz@google.com>2016-08-04 17:56:53 -0700
committerVineet Gupta <vgupta@synopsys.com>2016-08-10 10:14:07 -0700
commit18b43e89d295cc65151c505c643c98fb2c320e59 (patch)
tree6a4b3936ca2d3fbfdb577f6525d18b468f19879c
parent29b4817d4018df78086157ea3a55c1d9424a7cfc (diff)
ARC: Call trace_hardirqs_on() before enabling irqs
trace_hardirqs_on_caller() in lockdep.c expects to be called before, not after interrupts are actually enabled. The following comment in kernel/locking/lockdep.c substantiates this claim: " /* * We're enabling irqs and according to our state above irqs weren't * already enabled, yet we find the hardware thinks they are in fact * enabled.. someone messed up their IRQ state tracing. */ " An example can be found in include/linux/irqflags.h: do { trace_hardirqs_on(); raw_local_irq_enable(); } while (0) Without this change, we hit the following DEBUG_LOCKS_WARN_ON. [ 7.760000] ------------[ cut here ]------------ [ 7.760000] WARNING: CPU: 0 PID: 1 at kernel/locking/lockdep.c:2711 resume_user_mode_begin+0x48/0xf0 [ 7.770000] DEBUG_LOCKS_WARN_ON(!irqs_disabled()) [ 7.780000] Modules linked in: [ 7.780000] CPU: 0 PID: 1 Comm: init Not tainted 4.7.0-00003-gc668bb9-dirty #366 [ 7.790000] [ 7.790000] Stack Trace: [ 7.790000] arc_unwind_core.constprop.1+0xa4/0x118 [ 7.800000] warn_slowpath_fmt+0x72/0x158 [ 7.800000] resume_user_mode_begin+0x48/0xf0 [ 7.810000] ---[ end trace 6f6a7a8fae20d2f0 ]--- Signed-off-by: Daniel Mentz <danielmentz@google.com> Cc: <stable@vger.kernel.org> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>