2 * collectd - src/netlink.c
3 * Copyright (C) 2007-2010 Florian octo Forster
4 * Copyright (C) 2008-2012 Sebastian Harl
5 * Copyright (C) 2013 Andreas Henriksson
6 * Copyright (C) 2013 Marc Fournier
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; only version 2 of the License is applicable.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 * Florian octo Forster <octo at collectd.org>
23 * Sebastian Harl <sh at tokkee.org>
24 * Andreas Henriksson <andreas at fatal.se>
25 * Marc Fournier <marc.fournier at camptocamp.com>
33 #include <asm/types.h>
35 #include <linux/netlink.h>
36 #include <linux/rtnetlink.h>
37 #if HAVE_LINUX_GEN_STATS_H
38 #include <linux/gen_stats.h>
40 #if HAVE_LINUX_PKT_SCHED_H
41 #include <linux/pkt_sched.h>
44 #include <libmnl/libmnl.h>
46 struct ir_link_stats_storage_s {
60 uint64_t rx_length_errors;
61 uint64_t rx_over_errors;
62 uint64_t rx_crc_errors;
63 uint64_t rx_frame_errors;
64 uint64_t rx_fifo_errors;
65 uint64_t rx_missed_errors;
67 uint64_t tx_aborted_errors;
68 uint64_t tx_carrier_errors;
69 uint64_t tx_fifo_errors;
70 uint64_t tx_heartbeat_errors;
71 uint64_t tx_window_errors;
74 union ir_link_stats_u {
75 struct rtnl_link_stats *stats32;
76 #ifdef HAVE_RTNL_LINK_STATS64
77 struct rtnl_link_stats64 *stats64;
81 typedef struct ir_ignorelist_s {
85 struct ir_ignorelist_s *next;
88 static int ir_ignorelist_invert = 1;
89 static ir_ignorelist_t *ir_ignorelist_head = NULL;
91 static struct mnl_socket *nl;
93 static char **iflist = NULL;
94 static size_t iflist_len = 0;
96 static const char *config_keys[] = {"Interface", "VerboseInterface",
98 "Filter", "IgnoreSelected"};
99 static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
101 static int add_ignorelist(const char *dev, const char *type, const char *inst) {
102 ir_ignorelist_t *entry;
104 entry = calloc(1, sizeof(*entry));
108 if (strcasecmp(dev, "All") != 0) {
109 entry->device = strdup(dev);
110 if (entry->device == NULL) {
116 entry->type = strdup(type);
117 if (entry->type == NULL) {
118 sfree(entry->device);
124 entry->inst = strdup(inst);
125 if (entry->inst == NULL) {
127 sfree(entry->device);
133 entry->next = ir_ignorelist_head;
134 ir_ignorelist_head = entry;
137 } /* int add_ignorelist */
140 * Checks wether a data set should be ignored. Returns `true' is the value
141 * should be ignored, `false' otherwise.
143 static int check_ignorelist(const char *dev, const char *type,
144 const char *type_instance) {
145 assert((dev != NULL) && (type != NULL));
147 if (ir_ignorelist_head == NULL)
148 return (ir_ignorelist_invert ? 0 : 1);
150 for (ir_ignorelist_t *i = ir_ignorelist_head; i != NULL; i = i->next) {
151 /* i->device == NULL => match all devices */
152 if ((i->device != NULL) && (strcasecmp(i->device, dev) != 0))
155 if (strcasecmp(i->type, type) != 0)
158 if ((i->inst != NULL) && (type_instance != NULL) &&
159 (strcasecmp(i->inst, type_instance) != 0))
162 DEBUG("netlink plugin: check_ignorelist: "
163 "(dev = %s; type = %s; inst = %s) matched "
164 "(dev = %s; type = %s; inst = %s)",
165 dev, type, type_instance == NULL ? "(nil)" : type_instance,
166 i->device == NULL ? "(nil)" : i->device, i->type,
167 i->inst == NULL ? "(nil)" : i->inst);
169 return (ir_ignorelist_invert ? 0 : 1);
172 return (ir_ignorelist_invert);
173 } /* int check_ignorelist */
175 static void submit_one(const char *dev, const char *type,
176 const char *type_instance, derive_t value) {
177 value_list_t vl = VALUE_LIST_INIT;
179 vl.values = &(value_t){.derive = value};
181 sstrncpy(vl.plugin, "netlink", sizeof(vl.plugin));
182 sstrncpy(vl.plugin_instance, dev, sizeof(vl.plugin_instance));
183 sstrncpy(vl.type, type, sizeof(vl.type));
185 if (type_instance != NULL)
186 sstrncpy(vl.type_instance, type_instance, sizeof(vl.type_instance));
188 plugin_dispatch_values(&vl);
189 } /* void submit_one */
191 static void submit_two(const char *dev, const char *type,
192 const char *type_instance, derive_t rx, derive_t tx) {
193 value_list_t vl = VALUE_LIST_INIT;
195 {.derive = rx}, {.derive = tx},
199 vl.values_len = STATIC_ARRAY_SIZE(values);
200 sstrncpy(vl.plugin, "netlink", sizeof(vl.plugin));
201 sstrncpy(vl.plugin_instance, dev, sizeof(vl.plugin_instance));
202 sstrncpy(vl.type, type, sizeof(vl.type));
204 if (type_instance != NULL)
205 sstrncpy(vl.type_instance, type_instance, sizeof(vl.type_instance));
207 plugin_dispatch_values(&vl);
208 } /* void submit_two */
210 static int update_iflist(struct ifinfomsg *msg, const char *dev) {
211 /* Update the `iflist'. It's used to know which interfaces exist and query
212 * them later for qdiscs and classes. */
213 if ((msg->ifi_index >= 0) && ((size_t)msg->ifi_index >= iflist_len)) {
216 temp = realloc(iflist, (msg->ifi_index + 1) * sizeof(char *));
218 ERROR("netlink plugin: update_iflist: realloc failed.");
222 memset(temp + iflist_len, '\0',
223 (msg->ifi_index + 1 - iflist_len) * sizeof(char *));
225 iflist_len = msg->ifi_index + 1;
227 if ((iflist[msg->ifi_index] == NULL) ||
228 (strcmp(iflist[msg->ifi_index], dev) != 0)) {
229 sfree(iflist[msg->ifi_index]);
230 iflist[msg->ifi_index] = strdup(dev);
234 } /* int update_iflist */
236 static void check_ignorelist_and_submit(const char *dev,
237 struct ir_link_stats_storage_s *stats) {
239 if (check_ignorelist(dev, "interface", NULL) == 0) {
240 submit_two(dev, "if_octets", NULL, stats->rx_bytes, stats->tx_bytes);
241 submit_two(dev, "if_packets", NULL, stats->rx_packets, stats->tx_packets);
242 submit_two(dev, "if_errors", NULL, stats->rx_errors, stats->tx_errors);
244 DEBUG("netlink plugin: Ignoring %s/interface.", dev);
247 if (check_ignorelist(dev, "if_detail", NULL) == 0) {
248 submit_two(dev, "if_dropped", NULL, stats->rx_dropped, stats->tx_dropped);
249 submit_one(dev, "if_multicast", NULL, stats->multicast);
250 submit_one(dev, "if_collisions", NULL, stats->collisions);
252 submit_one(dev, "if_rx_errors", "length", stats->rx_length_errors);
253 submit_one(dev, "if_rx_errors", "over", stats->rx_over_errors);
254 submit_one(dev, "if_rx_errors", "crc", stats->rx_crc_errors);
255 submit_one(dev, "if_rx_errors", "frame", stats->rx_frame_errors);
256 submit_one(dev, "if_rx_errors", "fifo", stats->rx_fifo_errors);
257 submit_one(dev, "if_rx_errors", "missed", stats->rx_missed_errors);
259 submit_one(dev, "if_tx_errors", "aborted", stats->tx_aborted_errors);
260 submit_one(dev, "if_tx_errors", "carrier", stats->tx_carrier_errors);
261 submit_one(dev, "if_tx_errors", "fifo", stats->tx_fifo_errors);
262 submit_one(dev, "if_tx_errors", "heartbeat", stats->tx_heartbeat_errors);
263 submit_one(dev, "if_tx_errors", "window", stats->tx_window_errors);
265 DEBUG("netlink plugin: Ignoring %s/if_detail.", dev);
268 } /* void check_ignorelist_and_submit */
270 #define COPY_RTNL_LINK_VALUE(dst_stats, src_stats, value_name) \
271 (dst_stats)->value_name = (src_stats)->value_name
273 #define COPY_RTNL_LINK_STATS(dst_stats, src_stats) \
274 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, rx_packets); \
275 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, tx_packets); \
276 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, rx_bytes); \
277 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, tx_bytes); \
278 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, rx_errors); \
279 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, tx_errors); \
280 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, rx_dropped); \
281 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, tx_dropped); \
282 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, multicast); \
283 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, collisions); \
284 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, rx_length_errors); \
285 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, rx_over_errors); \
286 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, rx_crc_errors); \
287 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, rx_frame_errors); \
288 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, rx_fifo_errors); \
289 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, rx_missed_errors); \
290 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, tx_aborted_errors); \
291 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, tx_carrier_errors); \
292 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, tx_fifo_errors); \
293 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, tx_heartbeat_errors); \
294 COPY_RTNL_LINK_VALUE(dst_stats, src_stats, tx_window_errors)
296 #ifdef HAVE_RTNL_LINK_STATS64
297 static void check_ignorelist_and_submit64(const char *dev,
298 struct rtnl_link_stats64 *stats) {
299 struct ir_link_stats_storage_s s;
301 COPY_RTNL_LINK_STATS(&s, stats);
303 check_ignorelist_and_submit(dev, &s);
307 static void check_ignorelist_and_submit32(const char *dev,
308 struct rtnl_link_stats *stats) {
309 struct ir_link_stats_storage_s s;
311 COPY_RTNL_LINK_STATS(&s, stats);
313 check_ignorelist_and_submit(dev, &s);
316 static int link_filter_cb(const struct nlmsghdr *nlh,
317 void *args __attribute__((unused))) {
318 struct ifinfomsg *ifm = mnl_nlmsg_get_payload(nlh);
320 const char *dev = NULL;
321 union ir_link_stats_u stats;
323 if (nlh->nlmsg_type != RTM_NEWLINK) {
324 ERROR("netlink plugin: link_filter_cb: Don't know how to handle type %i.",
329 /* Scan attribute list for device name. */
330 mnl_attr_for_each(attr, nlh, sizeof(*ifm)) {
331 if (mnl_attr_get_type(attr) != IFLA_IFNAME)
334 if (mnl_attr_validate(attr, MNL_TYPE_STRING) < 0) {
335 ERROR("netlink plugin: link_filter_cb: IFLA_IFNAME mnl_attr_validate "
340 dev = mnl_attr_get_str(attr);
341 if (update_iflist(ifm, dev) < 0)
347 ERROR("netlink plugin: link_filter_cb: dev == NULL");
350 #ifdef HAVE_RTNL_LINK_STATS64
351 mnl_attr_for_each(attr, nlh, sizeof(*ifm)) {
352 if (mnl_attr_get_type(attr) != IFLA_STATS64)
355 if (mnl_attr_validate2(attr, MNL_TYPE_UNSPEC, sizeof(*stats.stats64)) < 0) {
357 ERROR("netlink plugin: link_filter_cb: IFLA_STATS64 mnl_attr_validate2 "
359 sstrerror(errno, errbuf, sizeof(errbuf)));
362 stats.stats64 = mnl_attr_get_payload(attr);
364 check_ignorelist_and_submit64(dev, stats.stats64);
369 mnl_attr_for_each(attr, nlh, sizeof(*ifm)) {
370 if (mnl_attr_get_type(attr) != IFLA_STATS)
373 if (mnl_attr_validate2(attr, MNL_TYPE_UNSPEC, sizeof(*stats.stats32)) < 0) {
375 ERROR("netlink plugin: link_filter_cb: IFLA_STATS mnl_attr_validate2 "
377 sstrerror(errno, errbuf, sizeof(errbuf)));
380 stats.stats32 = mnl_attr_get_payload(attr);
382 check_ignorelist_and_submit32(dev, stats.stats32);
387 DEBUG("netlink plugin: link_filter: No statistics for interface %s.", dev);
390 } /* int link_filter_cb */
393 static int qos_attr_cb(const struct nlattr *attr, void *data) {
394 struct gnet_stats_basic **bs = (struct gnet_stats_basic **)data;
396 /* skip unsupported attribute in user-space */
397 if (mnl_attr_type_valid(attr, TCA_STATS_MAX) < 0)
400 if (mnl_attr_get_type(attr) == TCA_STATS_BASIC) {
401 if (mnl_attr_validate2(attr, MNL_TYPE_UNSPEC, sizeof(**bs)) < 0) {
403 ERROR("netlink plugin: qos_attr_cb: TCA_STATS_BASIC mnl_attr_validate2 "
405 sstrerror(errno, errbuf, sizeof(errbuf)));
408 *bs = mnl_attr_get_payload(attr);
416 static int qos_filter_cb(const struct nlmsghdr *nlh, void *args) {
417 struct tcmsg *tm = mnl_nlmsg_get_payload(nlh);
420 int wanted_ifindex = *((int *)args);
423 const char *kind = NULL;
425 /* char *type_instance; */
427 char tc_inst[DATA_MAX_NAME_LEN];
429 _Bool stats_submitted = 0;
431 if (nlh->nlmsg_type == RTM_NEWQDISC)
433 else if (nlh->nlmsg_type == RTM_NEWTCLASS)
435 else if (nlh->nlmsg_type == RTM_NEWTFILTER)
438 ERROR("netlink plugin: qos_filter_cb: Don't know how to handle type %i.",
443 if (tm->tcm_ifindex != wanted_ifindex) {
444 DEBUG("netlink plugin: qos_filter_cb: Got %s for interface #%i, "
446 tc_type, tm->tcm_ifindex, wanted_ifindex);
450 if ((tm->tcm_ifindex >= 0) && ((size_t)tm->tcm_ifindex >= iflist_len)) {
451 ERROR("netlink plugin: qos_filter_cb: tm->tcm_ifindex = %i "
452 ">= iflist_len = %zu",
453 tm->tcm_ifindex, iflist_len);
457 dev = iflist[tm->tcm_ifindex];
459 ERROR("netlink plugin: qos_filter_cb: iflist[%i] == NULL", tm->tcm_ifindex);
463 mnl_attr_for_each(attr, nlh, sizeof(*tm)) {
464 if (mnl_attr_get_type(attr) != TCA_KIND)
467 if (mnl_attr_validate(attr, MNL_TYPE_STRING) < 0) {
469 "netlink plugin: qos_filter_cb: TCA_KIND mnl_attr_validate failed.");
473 kind = mnl_attr_get_str(attr);
478 ERROR("netlink plugin: qos_filter_cb: kind == NULL");
483 uint32_t numberic_id;
485 numberic_id = tm->tcm_handle;
486 if (strcmp(tc_type, "filter") == 0)
487 numberic_id = tm->tcm_parent;
489 ssnprintf(tc_inst, sizeof(tc_inst), "%s-%x:%x", kind, numberic_id >> 16,
490 numberic_id & 0x0000FFFF);
493 DEBUG("netlink plugin: qos_filter_cb: got %s for %s (%i).", tc_type, dev,
496 if (check_ignorelist(dev, tc_type, tc_inst))
500 mnl_attr_for_each(attr, nlh, sizeof(*tm)) {
501 struct gnet_stats_basic *bs = NULL;
503 if (mnl_attr_get_type(attr) != TCA_STATS2)
506 if (mnl_attr_validate(attr, MNL_TYPE_NESTED) < 0) {
507 ERROR("netlink plugin: qos_filter_cb: TCA_STATS2 mnl_attr_validate "
512 mnl_attr_parse_nested(attr, qos_attr_cb, &bs);
515 char type_instance[DATA_MAX_NAME_LEN];
519 ssnprintf(type_instance, sizeof(type_instance), "%s-%s", tc_type,
522 submit_one(dev, "ipt_bytes", type_instance, bs->bytes);
523 submit_one(dev, "ipt_packets", type_instance, bs->packets);
528 #endif /* TCA_STATS2 */
531 mnl_attr_for_each(attr, nlh, sizeof(*tm)) {
532 struct tc_stats *ts = NULL;
534 if (mnl_attr_get_type(attr) != TCA_STATS)
537 if (mnl_attr_validate2(attr, MNL_TYPE_UNSPEC, sizeof(*ts)) < 0) {
539 ERROR("netlink plugin: qos_filter_cb: TCA_STATS mnl_attr_validate2 "
541 sstrerror(errno, errbuf, sizeof(errbuf)));
544 ts = mnl_attr_get_payload(attr);
546 if (!stats_submitted && ts != NULL) {
547 char type_instance[DATA_MAX_NAME_LEN];
549 ssnprintf(type_instance, sizeof(type_instance), "%s-%s", tc_type,
552 submit_one(dev, "ipt_bytes", type_instance, ts->bytes);
553 submit_one(dev, "ipt_packets", type_instance, ts->packets);
559 #endif /* TCA_STATS */
561 #if !(HAVE_TCA_STATS && HAVE_TCA_STATS2)
562 DEBUG("netlink plugin: qos_filter_cb: Have neither TCA_STATS2 nor "
567 } /* int qos_filter_cb */
569 static int ir_config(const char *key, const char *value) {
575 new_val = strdup(value);
579 fields_num = strsplit(new_val, fields, STATIC_ARRAY_SIZE(fields));
580 if ((fields_num < 1) || (fields_num > 8)) {
585 if ((strcasecmp(key, "Interface") == 0) ||
586 (strcasecmp(key, "VerboseInterface") == 0)) {
587 if (fields_num != 1) {
588 ERROR("netlink plugin: Invalid number of fields for option "
589 "`%s'. Got %i, expected 1.",
593 add_ignorelist(fields[0], "interface", NULL);
594 if (strcasecmp(key, "VerboseInterface") == 0)
595 add_ignorelist(fields[0], "if_detail", NULL);
598 } else if ((strcasecmp(key, "QDisc") == 0) ||
599 (strcasecmp(key, "Class") == 0) ||
600 (strcasecmp(key, "Filter") == 0)) {
601 if ((fields_num < 1) || (fields_num > 2)) {
602 ERROR("netlink plugin: Invalid number of fields for option "
603 "`%s'. Got %i, expected 1 or 2.",
607 add_ignorelist(fields[0], key, (fields_num == 2) ? fields[1] : NULL);
610 } else if (strcasecmp(key, "IgnoreSelected") == 0) {
611 if (fields_num != 1) {
612 ERROR("netlink plugin: Invalid number of fields for option "
613 "`IgnoreSelected'. Got %i, expected 1.",
617 if (IS_TRUE(fields[0]))
618 ir_ignorelist_invert = 0;
620 ir_ignorelist_invert = 1;
628 } /* int ir_config */
630 static int ir_init(void) {
631 nl = mnl_socket_open(NETLINK_ROUTE);
633 ERROR("netlink plugin: ir_init: mnl_socket_open failed.");
637 if (mnl_socket_bind(nl, 0, MNL_SOCKET_AUTOPID) < 0) {
638 ERROR("netlink plugin: ir_init: mnl_socket_bind failed.");
645 static int ir_read(void) {
646 char buf[MNL_SOCKET_BUFFER_SIZE];
647 struct nlmsghdr *nlh;
650 unsigned int seq, portid;
652 static const int type_id[] = {RTM_GETQDISC, RTM_GETTCLASS, RTM_GETTFILTER};
653 static const char *type_name[] = {"qdisc", "class", "filter"};
655 portid = mnl_socket_get_portid(nl);
657 nlh = mnl_nlmsg_put_header(buf);
658 nlh->nlmsg_type = RTM_GETLINK;
659 nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
660 nlh->nlmsg_seq = seq = time(NULL);
661 rt = mnl_nlmsg_put_extra_header(nlh, sizeof(*rt));
662 rt->rtgen_family = AF_PACKET;
664 if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
665 ERROR("netlink plugin: ir_read: rtnl_wilddump_request failed.");
669 ret = mnl_socket_recvfrom(nl, buf, sizeof(buf));
671 ret = mnl_cb_run(buf, ret, seq, portid, link_filter_cb, NULL);
672 if (ret <= MNL_CB_STOP)
674 ret = mnl_socket_recvfrom(nl, buf, sizeof(buf));
678 ERROR("netlink plugin: ir_read: mnl_socket_recvfrom failed: %s",
679 sstrerror(errno, errbuf, sizeof(errbuf)));
683 /* `link_filter_cb' will update `iflist' which is used here to iterate
684 * over all interfaces. */
685 for (size_t ifindex = 1; ifindex < iflist_len; ifindex++) {
688 if (iflist[ifindex] == NULL)
691 for (size_t type_index = 0; type_index < STATIC_ARRAY_SIZE(type_id);
693 if (check_ignorelist(iflist[ifindex], type_name[type_index], NULL)) {
694 DEBUG("netlink plugin: ir_read: check_ignorelist (%s, %s, (nil)) "
696 iflist[ifindex], type_name[type_index]);
700 DEBUG("netlink plugin: ir_read: querying %s from %s (%zu).",
701 type_name[type_index], iflist[ifindex], ifindex);
703 nlh = mnl_nlmsg_put_header(buf);
704 nlh->nlmsg_type = type_id[type_index];
705 nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
706 nlh->nlmsg_seq = seq = time(NULL);
707 tm = mnl_nlmsg_put_extra_header(nlh, sizeof(*tm));
708 tm->tcm_family = AF_PACKET;
709 tm->tcm_ifindex = ifindex;
711 if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
712 ERROR("netlink plugin: ir_read: mnl_socket_sendto failed.");
716 ret = mnl_socket_recvfrom(nl, buf, sizeof(buf));
718 ret = mnl_cb_run(buf, ret, seq, portid, qos_filter_cb, &ifindex);
719 if (ret <= MNL_CB_STOP)
721 ret = mnl_socket_recvfrom(nl, buf, sizeof(buf));
725 ERROR("netlink plugin: ir_read: mnl_socket_recvfrom failed: %s",
726 sstrerror(errno, errbuf, sizeof(errbuf)));
729 } /* for (type_index) */
730 } /* for (if_index) */
735 static int ir_shutdown(void) {
737 mnl_socket_close(nl);
742 } /* int ir_shutdown */
744 void module_register(void) {
745 plugin_register_config("netlink", ir_config, config_keys, config_keys_num);
746 plugin_register_init("netlink", ir_init);
747 plugin_register_read("netlink", ir_read);
748 plugin_register_shutdown("netlink", ir_shutdown);
749 } /* void module_register */
752 * vim: set shiftwidth=2 softtabstop=2 tabstop=8 :