aboutsummaryrefslogtreecommitdiffstats
path: root/net/netlabel
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-02-18 01:33:16 -0500
committerDavid S. Miller <davem@davemloft.net>2008-02-18 01:33:16 -0500
commit227c43c3bca76df704231324405980851dc7f528 (patch)
tree6b6f32246a974382cc6b7d6474a18c225603a856 /net/netlabel
parentf47b7257c7368698eabff6fd7b340071932af640 (diff)
[NETLABEL]: Shrink the genl-ops registration code.
Turning them to array and registration in a loop saves 80 lines of code and ~300 bytes from text section. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Acked-by: Paul Moore <paul.moore@hp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netlabel')
-rw-r--r--net/netlabel/netlabel_cipso_v4.c43
-rw-r--r--net/netlabel/netlabel_mgmt.c79
-rw-r--r--net/netlabel/netlabel_unlabeled.c86
3 files changed, 64 insertions, 144 deletions
diff --git a/net/netlabel/netlabel_cipso_v4.c b/net/netlabel/netlabel_cipso_v4.c
index c7ad64d664ad..283ff4a527fd 100644
--- a/net/netlabel/netlabel_cipso_v4.c
+++ b/net/netlabel/netlabel_cipso_v4.c
@@ -718,36 +718,35 @@ static int netlbl_cipsov4_remove(struct sk_buff *skb, struct genl_info *info)
718 * NetLabel Generic NETLINK Command Definitions 718 * NetLabel Generic NETLINK Command Definitions
719 */ 719 */
720 720
721static struct genl_ops netlbl_cipsov4_genl_c_add = { 721static struct genl_ops netlbl_cipsov4_ops[] = {
722 {
722 .cmd = NLBL_CIPSOV4_C_ADD, 723 .cmd = NLBL_CIPSOV4_C_ADD,
723 .flags = GENL_ADMIN_PERM, 724 .flags = GENL_ADMIN_PERM,
724 .policy = netlbl_cipsov4_genl_policy, 725 .policy = netlbl_cipsov4_genl_policy,
725 .doit = netlbl_cipsov4_add, 726 .doit = netlbl_cipsov4_add,
726 .dumpit = NULL, 727 .dumpit = NULL,
727}; 728 },
728 729 {
729static struct genl_ops netlbl_cipsov4_genl_c_remove = {
730 .cmd = NLBL_CIPSOV4_C_REMOVE, 730 .cmd = NLBL_CIPSOV4_C_REMOVE,
731 .flags = GENL_ADMIN_PERM, 731 .flags = GENL_ADMIN_PERM,
732 .policy = netlbl_cipsov4_genl_policy, 732 .policy = netlbl_cipsov4_genl_policy,
733 .doit = netlbl_cipsov4_remove, 733 .doit = netlbl_cipsov4_remove,
734 .dumpit = NULL, 734 .dumpit = NULL,
735}; 735 },
736 736 {
737static struct genl_ops netlbl_cipsov4_genl_c_list = {
738 .cmd = NLBL_CIPSOV4_C_LIST, 737 .cmd = NLBL_CIPSOV4_C_LIST,
739 .flags = 0, 738 .flags = 0,
740 .policy = netlbl_cipsov4_genl_policy, 739 .policy = netlbl_cipsov4_genl_policy,
741 .doit = netlbl_cipsov4_list, 740 .doit = netlbl_cipsov4_list,
742 .dumpit = NULL, 741 .dumpit = NULL,
743}; 742 },
744 743 {
745static struct genl_ops netlbl_cipsov4_genl_c_listall = {
746 .cmd = NLBL_CIPSOV4_C_LISTALL, 744 .cmd = NLBL_CIPSOV4_C_LISTALL,
747 .flags = 0, 745 .flags = 0,
748 .policy = netlbl_cipsov4_genl_policy, 746 .policy = netlbl_cipsov4_genl_policy,
749 .doit = NULL, 747 .doit = NULL,
750 .dumpit = netlbl_cipsov4_listall, 748 .dumpit = netlbl_cipsov4_listall,
749 },
751}; 750};
752 751
753/* 752/*
@@ -764,28 +763,18 @@ static struct genl_ops netlbl_cipsov4_genl_c_listall = {
764 */ 763 */
765int netlbl_cipsov4_genl_init(void) 764int netlbl_cipsov4_genl_init(void)
766{ 765{
767 int ret_val; 766 int ret_val, i;
768 767
769 ret_val = genl_register_family(&netlbl_cipsov4_gnl_family); 768 ret_val = genl_register_family(&netlbl_cipsov4_gnl_family);
770 if (ret_val != 0) 769 if (ret_val != 0)
771 return ret_val; 770 return ret_val;
772 771
773 ret_val = genl_register_ops(&netlbl_cipsov4_gnl_family, 772 for (i = 0; i < ARRAY_SIZE(netlbl_cipsov4_ops); i++) {
774 &netlbl_cipsov4_genl_c_add); 773 ret_val = genl_register_ops(&netlbl_cipsov4_gnl_family,
775 if (ret_val != 0) 774 &netlbl_cipsov4_ops[i]);
776 return ret_val; 775 if (ret_val != 0)
777 ret_val = genl_register_ops(&netlbl_cipsov4_gnl_family, 776 return ret_val;
778 &netlbl_cipsov4_genl_c_remove); 777 }
779 if (ret_val != 0)
780 return ret_val;
781 ret_val = genl_register_ops(&netlbl_cipsov4_gnl_family,
782 &netlbl_cipsov4_genl_c_list);
783 if (ret_val != 0)
784 return ret_val;
785 ret_val = genl_register_ops(&netlbl_cipsov4_gnl_family,
786 &netlbl_cipsov4_genl_c_listall);
787 if (ret_val != 0)
788 return ret_val;
789 778
790 return 0; 779 return 0;
791} 780}
diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
index e2258dc3c845..05d98862fbd4 100644
--- a/net/netlabel/netlabel_mgmt.c
+++ b/net/netlabel/netlabel_mgmt.c
@@ -517,68 +517,63 @@ version_failure:
517 * NetLabel Generic NETLINK Command Definitions 517 * NetLabel Generic NETLINK Command Definitions
518 */ 518 */
519 519
520static struct genl_ops netlbl_mgmt_genl_c_add = { 520static struct genl_ops netlbl_mgmt_genl_ops[] = {
521 {
521 .cmd = NLBL_MGMT_C_ADD, 522 .cmd = NLBL_MGMT_C_ADD,
522 .flags = GENL_ADMIN_PERM, 523 .flags = GENL_ADMIN_PERM,
523 .policy = netlbl_mgmt_genl_policy, 524 .policy = netlbl_mgmt_genl_policy,
524 .doit = netlbl_mgmt_add, 525 .doit = netlbl_mgmt_add,
525 .dumpit = NULL, 526 .dumpit = NULL,
526}; 527 },
527 528 {
528static struct genl_ops netlbl_mgmt_genl_c_remove = {
529 .cmd = NLBL_MGMT_C_REMOVE, 529 .cmd = NLBL_MGMT_C_REMOVE,
530 .flags = GENL_ADMIN_PERM, 530 .flags = GENL_ADMIN_PERM,
531 .policy = netlbl_mgmt_genl_policy, 531 .policy = netlbl_mgmt_genl_policy,
532 .doit = netlbl_mgmt_remove, 532 .doit = netlbl_mgmt_remove,
533 .dumpit = NULL, 533 .dumpit = NULL,
534}; 534 },
535 535 {
536static struct genl_ops netlbl_mgmt_genl_c_listall = {
537 .cmd = NLBL_MGMT_C_LISTALL, 536 .cmd = NLBL_MGMT_C_LISTALL,
538 .flags = 0, 537 .flags = 0,
539 .policy = netlbl_mgmt_genl_policy, 538 .policy = netlbl_mgmt_genl_policy,
540 .doit = NULL, 539 .doit = NULL,
541 .dumpit = netlbl_mgmt_listall, 540 .dumpit = netlbl_mgmt_listall,
542}; 541 },
543 542 {
544static struct genl_ops netlbl_mgmt_genl_c_adddef = {
545 .cmd = NLBL_MGMT_C_ADDDEF, 543 .cmd = NLBL_MGMT_C_ADDDEF,
546 .flags = GENL_ADMIN_PERM, 544 .flags = GENL_ADMIN_PERM,
547 .policy = netlbl_mgmt_genl_policy, 545 .policy = netlbl_mgmt_genl_policy,
548 .doit = netlbl_mgmt_adddef, 546 .doit = netlbl_mgmt_adddef,
549 .dumpit = NULL, 547 .dumpit = NULL,
550}; 548 },
551 549 {
552static struct genl_ops netlbl_mgmt_genl_c_removedef = {
553 .cmd = NLBL_MGMT_C_REMOVEDEF, 550 .cmd = NLBL_MGMT_C_REMOVEDEF,
554 .flags = GENL_ADMIN_PERM, 551 .flags = GENL_ADMIN_PERM,
555 .policy = netlbl_mgmt_genl_policy, 552 .policy = netlbl_mgmt_genl_policy,
556 .doit = netlbl_mgmt_removedef, 553 .doit = netlbl_mgmt_removedef,
557 .dumpit = NULL, 554 .dumpit = NULL,
558}; 555 },
559 556 {
560static struct genl_ops netlbl_mgmt_genl_c_listdef = {
561 .cmd = NLBL_MGMT_C_LISTDEF, 557 .cmd = NLBL_MGMT_C_LISTDEF,
562 .flags = 0, 558 .flags = 0,
563 .policy = netlbl_mgmt_genl_policy, 559 .policy = netlbl_mgmt_genl_policy,
564 .doit = netlbl_mgmt_listdef, 560 .doit = netlbl_mgmt_listdef,
565 .dumpit = NULL, 561 .dumpit = NULL,
566}; 562 },
567 563 {
568static struct genl_ops netlbl_mgmt_genl_c_protocols = {
569 .cmd = NLBL_MGMT_C_PROTOCOLS, 564 .cmd = NLBL_MGMT_C_PROTOCOLS,
570 .flags = 0, 565 .flags = 0,
571 .policy = netlbl_mgmt_genl_policy, 566 .policy = netlbl_mgmt_genl_policy,
572 .doit = NULL, 567 .doit = NULL,
573 .dumpit = netlbl_mgmt_protocols, 568 .dumpit = netlbl_mgmt_protocols,
574}; 569 },
575 570 {
576static struct genl_ops netlbl_mgmt_genl_c_version = {
577 .cmd = NLBL_MGMT_C_VERSION, 571 .cmd = NLBL_MGMT_C_VERSION,
578 .flags = 0, 572 .flags = 0,
579 .policy = netlbl_mgmt_genl_policy, 573 .policy = netlbl_mgmt_genl_policy,
580 .doit = netlbl_mgmt_version, 574 .doit = netlbl_mgmt_version,
581 .dumpit = NULL, 575 .dumpit = NULL,
576 },
582}; 577};
583 578
584/* 579/*
@@ -595,44 +590,18 @@ static struct genl_ops netlbl_mgmt_genl_c_version = {
595 */ 590 */
596int netlbl_mgmt_genl_init(void) 591int netlbl_mgmt_genl_init(void)
597{ 592{
598 int ret_val; 593 int ret_val, i;
599 594
600 ret_val = genl_register_family(&netlbl_mgmt_gnl_family); 595 ret_val = genl_register_family(&netlbl_mgmt_gnl_family);
601 if (ret_val != 0) 596 if (ret_val != 0)
602 return ret_val; 597 return ret_val;
603 598
604 ret_val = genl_register_ops(&netlbl_mgmt_gnl_family, 599 for (i = 0; i < ARRAY_SIZE(netlbl_mgmt_genl_ops); i++) {
605 &netlbl_mgmt_genl_c_add); 600 ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
606 if (ret_val != 0) 601 &netlbl_mgmt_genl_ops[i]);
607 return ret_val; 602 if (ret_val != 0)
608 ret_val = genl_register_ops(&netlbl_mgmt_gnl_family, 603 return ret_val;
609 &netlbl_mgmt_genl_c_remove); 604 }
610 if (ret_val != 0)
611 return ret_val;
612 ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
613 &netlbl_mgmt_genl_c_listall);
614 if (ret_val != 0)
615 return ret_val;
616 ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
617 &netlbl_mgmt_genl_c_adddef);
618 if (ret_val != 0)
619 return ret_val;
620 ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
621 &netlbl_mgmt_genl_c_removedef);
622 if (ret_val != 0)
623 return ret_val;
624 ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
625 &netlbl_mgmt_genl_c_listdef);
626 if (ret_val != 0)
627 return ret_val;
628 ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
629 &netlbl_mgmt_genl_c_protocols);
630 if (ret_val != 0)
631 return ret_val;
632 ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
633 &netlbl_mgmt_genl_c_version);
634 if (ret_val != 0)
635 return ret_val;
636 605
637 return 0; 606 return 0;
638} 607}
diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c
index 3e745b72fded..f0f1322911de 100644
--- a/net/netlabel/netlabel_unlabeled.c
+++ b/net/netlabel/netlabel_unlabeled.c
@@ -1553,68 +1553,63 @@ unlabel_staticlistdef_return:
1553 * NetLabel Generic NETLINK Command Definitions 1553 * NetLabel Generic NETLINK Command Definitions
1554 */ 1554 */
1555 1555
1556static struct genl_ops netlbl_unlabel_genl_c_staticadd = { 1556static struct genl_ops netlbl_unlabel_genl_ops[] = {
1557 {
1557 .cmd = NLBL_UNLABEL_C_STATICADD, 1558 .cmd = NLBL_UNLABEL_C_STATICADD,
1558 .flags = GENL_ADMIN_PERM, 1559 .flags = GENL_ADMIN_PERM,
1559 .policy = netlbl_unlabel_genl_policy, 1560 .policy = netlbl_unlabel_genl_policy,
1560 .doit = netlbl_unlabel_staticadd, 1561 .doit = netlbl_unlabel_staticadd,
1561 .dumpit = NULL, 1562 .dumpit = NULL,
1562}; 1563 },
1563 1564 {
1564static struct genl_ops netlbl_unlabel_genl_c_staticremove = {
1565 .cmd = NLBL_UNLABEL_C_STATICREMOVE, 1565 .cmd = NLBL_UNLABEL_C_STATICREMOVE,
1566 .flags = GENL_ADMIN_PERM, 1566 .flags = GENL_ADMIN_PERM,
1567 .policy = netlbl_unlabel_genl_policy, 1567 .policy = netlbl_unlabel_genl_policy,
1568 .doit = netlbl_unlabel_staticremove, 1568 .doit = netlbl_unlabel_staticremove,
1569 .dumpit = NULL, 1569 .dumpit = NULL,
1570}; 1570 },
1571 1571 {
1572static struct genl_ops netlbl_unlabel_genl_c_staticlist = {
1573 .cmd = NLBL_UNLABEL_C_STATICLIST, 1572 .cmd = NLBL_UNLABEL_C_STATICLIST,
1574 .flags = 0, 1573 .flags = 0,
1575 .policy = netlbl_unlabel_genl_policy, 1574 .policy = netlbl_unlabel_genl_policy,
1576 .doit = NULL, 1575 .doit = NULL,
1577 .dumpit = netlbl_unlabel_staticlist, 1576 .dumpit = netlbl_unlabel_staticlist,
1578}; 1577 },
1579 1578 {
1580static struct genl_ops netlbl_unlabel_genl_c_staticadddef = {
1581 .cmd = NLBL_UNLABEL_C_STATICADDDEF, 1579 .cmd = NLBL_UNLABEL_C_STATICADDDEF,
1582 .flags = GENL_ADMIN_PERM, 1580 .flags = GENL_ADMIN_PERM,
1583 .policy = netlbl_unlabel_genl_policy, 1581 .policy = netlbl_unlabel_genl_policy,
1584 .doit = netlbl_unlabel_staticadddef, 1582 .doit = netlbl_unlabel_staticadddef,
1585 .dumpit = NULL, 1583 .dumpit = NULL,
1586}; 1584 },
1587 1585 {
1588static struct genl_ops netlbl_unlabel_genl_c_staticremovedef = {
1589 .cmd = NLBL_UNLABEL_C_STATICREMOVEDEF, 1586 .cmd = NLBL_UNLABEL_C_STATICREMOVEDEF,
1590 .flags = GENL_ADMIN_PERM, 1587 .flags = GENL_ADMIN_PERM,
1591 .policy = netlbl_unlabel_genl_policy, 1588 .policy = netlbl_unlabel_genl_policy,
1592 .doit = netlbl_unlabel_staticremovedef, 1589 .doit = netlbl_unlabel_staticremovedef,
1593 .dumpit = NULL, 1590 .dumpit = NULL,
1594}; 1591 },
1595 1592 {
1596static struct genl_ops netlbl_unlabel_genl_c_staticlistdef = {
1597 .cmd = NLBL_UNLABEL_C_STATICLISTDEF, 1593 .cmd = NLBL_UNLABEL_C_STATICLISTDEF,
1598 .flags = 0, 1594 .flags = 0,
1599 .policy = netlbl_unlabel_genl_policy, 1595 .policy = netlbl_unlabel_genl_policy,
1600 .doit = NULL, 1596 .doit = NULL,
1601 .dumpit = netlbl_unlabel_staticlistdef, 1597 .dumpit = netlbl_unlabel_staticlistdef,
1602}; 1598 },
1603 1599 {
1604static struct genl_ops netlbl_unlabel_genl_c_accept = {
1605 .cmd = NLBL_UNLABEL_C_ACCEPT, 1600 .cmd = NLBL_UNLABEL_C_ACCEPT,
1606 .flags = GENL_ADMIN_PERM, 1601 .flags = GENL_ADMIN_PERM,
1607 .policy = netlbl_unlabel_genl_policy, 1602 .policy = netlbl_unlabel_genl_policy,
1608 .doit = netlbl_unlabel_accept, 1603 .doit = netlbl_unlabel_accept,
1609 .dumpit = NULL, 1604 .dumpit = NULL,
1610}; 1605 },
1611 1606 {
1612static struct genl_ops netlbl_unlabel_genl_c_list = {
1613 .cmd = NLBL_UNLABEL_C_LIST, 1607 .cmd = NLBL_UNLABEL_C_LIST,
1614 .flags = 0, 1608 .flags = 0,
1615 .policy = netlbl_unlabel_genl_policy, 1609 .policy = netlbl_unlabel_genl_policy,
1616 .doit = netlbl_unlabel_list, 1610 .doit = netlbl_unlabel_list,
1617 .dumpit = NULL, 1611 .dumpit = NULL,
1612 },
1618}; 1613};
1619 1614
1620/* 1615/*
@@ -1631,51 +1626,18 @@ static struct genl_ops netlbl_unlabel_genl_c_list = {
1631 */ 1626 */
1632int netlbl_unlabel_genl_init(void) 1627int netlbl_unlabel_genl_init(void)
1633{ 1628{
1634 int ret_val; 1629 int ret_val, i;
1635 1630
1636 ret_val = genl_register_family(&netlbl_unlabel_gnl_family); 1631 ret_val = genl_register_family(&netlbl_unlabel_gnl_family);
1637 if (ret_val != 0) 1632 if (ret_val != 0)
1638 return ret_val; 1633 return ret_val;
1639 1634
1640 ret_val = genl_register_ops(&netlbl_unlabel_gnl_family, 1635 for (i = 0; i < ARRAY_SIZE(netlbl_unlabel_genl_ops); i++) {
1641 &netlbl_unlabel_genl_c_staticadd); 1636 ret_val = genl_register_ops(&netlbl_unlabel_gnl_family,
1642 if (ret_val != 0) 1637 &netlbl_unlabel_genl_ops[i]);
1643 return ret_val; 1638 if (ret_val != 0)
1644 1639 return ret_val;
1645 ret_val = genl_register_ops(&netlbl_unlabel_gnl_family, 1640 }
1646 &netlbl_unlabel_genl_c_staticremove);
1647 if (ret_val != 0)
1648 return ret_val;
1649
1650 ret_val = genl_register_ops(&netlbl_unlabel_gnl_family,
1651 &netlbl_unlabel_genl_c_staticlist);
1652 if (ret_val != 0)
1653 return ret_val;
1654
1655 ret_val = genl_register_ops(&netlbl_unlabel_gnl_family,
1656 &netlbl_unlabel_genl_c_staticadddef);
1657 if (ret_val != 0)
1658 return ret_val;
1659
1660 ret_val = genl_register_ops(&netlbl_unlabel_gnl_family,
1661 &netlbl_unlabel_genl_c_staticremovedef);
1662 if (ret_val != 0)
1663 return ret_val;
1664
1665 ret_val = genl_register_ops(&netlbl_unlabel_gnl_family,
1666 &netlbl_unlabel_genl_c_staticlistdef);
1667 if (ret_val != 0)
1668 return ret_val;
1669
1670 ret_val = genl_register_ops(&netlbl_unlabel_gnl_family,
1671 &netlbl_unlabel_genl_c_accept);
1672 if (ret_val != 0)
1673 return ret_val;
1674
1675 ret_val = genl_register_ops(&netlbl_unlabel_gnl_family,
1676 &netlbl_unlabel_genl_c_list);
1677 if (ret_val != 0)
1678 return ret_val;
1679 1641
1680 return 0; 1642 return 0;
1681} 1643}