aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid M. Syzdek <syzdek@bindlebinaries.com>2019-05-24 14:12:16 -0800
committerDavid M. Syzdek <syzdek@bindlebinaries.com>2019-05-24 14:12:16 -0800
commitefbbc604314735edbf4bd0edd23017c05d680961 (patch)
tree3c55f504c1f0d4135d3e940f13ccdf47f5e31792
parentbb6abb698da039bd6609b730fc1052444eccbf42 (diff)
downloadscratchpad-efbbc604314735edbf4bd0edd23017c05d680961.tar.gz
scratchpad-efbbc604314735edbf4bd0edd23017c05d680961.tar.bz2
scratchpad-efbbc604314735edbf4bd0edd23017c05d680961.tar.xz
scratchpad-efbbc604314735edbf4bd0edd23017c05d680961.zip
Updating documentation
-rw-r--r--notes/projects/radius/sql/README.ippool.md84
-rw-r--r--notes/projects/radius/sql/ippool-functions.sql148
2 files changed, 215 insertions, 17 deletions
diff --git a/notes/projects/radius/sql/README.ippool.md b/notes/projects/radius/sql/README.ippool.md
index b463df8..d6ed50f 100644
--- a/notes/projects/radius/sql/README.ippool.md
+++ b/notes/projects/radius/sql/README.ippool.md
@@ -5,7 +5,7 @@ IP Engineering RADIUS IP Pool Database
5Objectives 5Objectives
6---------- 6----------
7 7
8 * Psuedo static IP addresses 8 * Psuedo static IP addresses (i.e. "sticky" IP addresses)
9 * Per NAS Preference for geographic regions 9 * Per NAS Preference for geographic regions
10 * Ability to deavtivate/busy out specific netblocks 10 * Ability to deavtivate/busy out specific netblocks
11 11
@@ -77,10 +77,88 @@ The following PostgreSQL (psql) commands will purge RADIUS roles from Postgresql
77 DROP ROLE radius; 77 DROP ROLE radius;
78 78
79 79
80Network Block Management 80Auditing Reports
81------------------------ 81----------------
82 82
83The following displays IP usage by IP pool:
84
85 SELECT * FROM pool_audit() ORDER BY poolname, regionType;
86
87The following displays IP usage by IP pool and region:
88
89 SELECT * FROM region_audit() ORDER BY poolName, regionName;
90
91The following displays IP usage by defined netblocks:
92
93 SELECT * FROM netblock_audit() ORDER BY poolName, network;
94
95The following displays the state of each IP address:
96
97 SELECT * FROM ip_audit() ORDER BY ipAddress;
83 98
84 99
85IP Address Assignments 100IP Address Assignments
86---------------------- 101----------------------
102
103IP addresses can be manually assigned or auto-assigned based upon the NAS and
104pool type specified.
105
106The following is an example of manually specifing an IP address assignment:
107
108 SELECT ip_assign
109 ( assignIp := '209.193.4.8/32',
110 assignNas := 'br1.sol',
111 assignUser := 'jdoe8@example.net'
112 );
113
114The above assignment will fail if a netblock containing '209.193.4.8/32' has
115been marked as 'busyout'. A assignment to a busy netblock can be forced using
116the 'assignForce' option:
117
118 SELECT ip_assign
119 ( assignIp := '209.193.4.3/32',
120 assignNas := 'br1.sol',
121 assignUser := 'busy1@example.net',
122 assignForce := TRUE
123 );
124
125The following is an example of auto-assigning an IP address based upon a client
126session's NAS and pool type:
127
128 SELECT ip_autoassign
129 ( assignUser := 'autoassign1@example.net',
130 assignNas := 'br1.sol',
131 assignPool := 'dhcp'
132 );
133
134By default, `ip_autoassign()` will attempt to assign "sticky" IP addresses to a
135session. A sticky address is a best effort attempt to re-assign the IP address
136previously used by the subscriber. Sticky IP address assignments use the
137following logic to assign an IP address to a user session:
138
139 * Attempt to assign regional pool address which was last used by subscriber.
140 * Attempt to assign regional pool address which has been idle the longest.
141 * Attempt to assign non-regional pool address which was last used by subscriber.
142 * Attempt to assign non-regional pool address which has been idle the longest.
143 * Fail address assignment.
144
145Dynamic IP addresses can be requested by passing 'assignPrevIp' with a value of
146FALSE to `ip_autoassign()`:
147
148 SELECT ip_autoassign
149 ( assignUser := 'autoassign2@example.net',
150 assignNas := 'br1.sol',
151 assignPool := 'dhcp',
152 assignPrevIp := FALSE
153 );
154
155When assigning auto-assigning dynamic IP addresses, the following logic is used:
156
157 * Attempt to assign regional pool address which has been idle the longest.
158 * Attempt to assign non-regional pool address which has been idle the longest.
159 * Fail address assignment.
160
161Both manual and auto-assigned IP addresses are freed using `ip_release()`:
162
163 SELECT ip_release( '209.193.4.3' );
164
diff --git a/notes/projects/radius/sql/ippool-functions.sql b/notes/projects/radius/sql/ippool-functions.sql
index f7cc8c5..3bbabdf 100644
--- a/notes/projects/radius/sql/ippool-functions.sql
+++ b/notes/projects/radius/sql/ippool-functions.sql
@@ -223,7 +223,35 @@ $$;
223 * 223 *
224 * % SELECT * FROM ip_audit(); 224 * % SELECT * FROM ip_audit();
225 * 225 *
226 * Returns table of ip 226 * Returns table with the following columns:
227 *
228 * poolName
229 * : name of pool which owns IP address
230 *
231 * regionname
232 * : name of region which owns IP address or NULL if not assigned to a region
233 *
234 * ipAddress
235 * : the IP address of the current record
236 *
237 * busyout
238 * : if TRUE, IP address cannot be assigned without being forced
239 *
240 * assigned
241 * : if true, IP address is assigend to a session. If false, IP address is
242 * : available
243 *
244 * modified
245 * : time stamp of last assignment or release
246 *
247 * nasName
248 * : NAS name of current assignment, NULL if IP address is not assigned to a
249 * : session
250 *
251 * username
252 * : username of current subscriber if IP address is assigned or username of
253 * : prevsious subscriber if IP address is not currently assigned.
254 *
227 */ 255 */
228CREATE OR REPLACE FUNCTION ip_audit 256CREATE OR REPLACE FUNCTION ip_audit
229( 257(
@@ -447,9 +475,16 @@ $$;
447 475
448 476
449/* 477/*
450 * updates timestamp of addresses 478 * Releases IP address from current assignment
479 *
480 * % SELECT ip_release(
481 * assignIp := '209.193.4.1'
482 * )
483 *
484 * assignIp
485 * : IP address to release
451 * 486 *
452 * returns trigger 487 * returns TRUE if sucessful and FALSE if unsuccessful
453 */ 488 */
454CREATE OR REPLACE FUNCTION ip_release 489CREATE OR REPLACE FUNCTION ip_release
455( 490(
@@ -631,7 +666,36 @@ $$;
631 * 666 *
632 * % SELECT * FROM netblock_audit(); 667 * % SELECT * FROM netblock_audit();
633 * 668 *
634 * Returns table of netblocks 669 * Returns table with the following columns:
670 *
671 * poolName
672 * : name of pool which owns IP address
673 *
674 * regionname
675 * : name of region which owns IP address or NULL if not assigned to a region
676 *
677 * network
678 * : network address and CIDR of netblock
679 *
680 * busyout
681 * : if TRUE, IP address cannot be assigned without being forced
682 *
683 * ipAssigned
684 * : number of IP addresses assigned from netblock
685 *
686 * ipUnassigned
687 * : number of IP addresses in netblock which are not assigned
688 *
689 * ipAvailable
690 * : number of IP addresses in netblock available for assignment (i.e. not
691 * : busyout and not currently assigend)
692 *
693 * ipTotal
694 * : total number of IP addresses in netblock
695 *
696 * description
697 * : human readable description of netblock
698 *
635 */ 699 */
636CREATE OR REPLACE FUNCTION netblock_audit 700CREATE OR REPLACE FUNCTION netblock_audit
637( 701(
@@ -697,11 +761,39 @@ $$;
697 761
698 762
699/* 763/*
700 * audits netblocks 764 * audits pools
701 * 765 *
702 * % SELECT * FROM netblock_audit(); 766 * % SELECT * FROM netblock_pool();
767 *
768 * Returns table with the following columns:
769 *
770 * poolName
771 * : name of pool which owns IP address
772 *
773 * regionType
774 * : one of 'regional', 'non-regional', and 'TOTAL'
775 *
776 * ipAssignedFree
777 * : number of IP addresses which are currently not busyout and are assigend
778 * : to sessions
779 *
780 * ipAssignedBusy
781 * : number of IP addresses which are currently busyout and are assigend to
782 * : sessions
783 *
784 * ipAvailable
785 * : number of IP addresses which are currently not busyout and not assigned to
786 * : a session
787 *
788 * ipBusyout
789 * : number of IP addresses currently marked as busyout
790 *
791 * ipTotal
792 * : total number of IP addresses
793 *
794 * description
795 * : human readable description of record
703 * 796 *
704 * Returns table of netblocks
705 */ 797 */
706CREATE OR REPLACE FUNCTION pool_audit 798CREATE OR REPLACE FUNCTION pool_audit
707( 799(
@@ -709,7 +801,7 @@ CREATE OR REPLACE FUNCTION pool_audit
709 RETURNS TABLE 801 RETURNS TABLE
710 ( 802 (
711 poolName VARCHAR(32), 803 poolName VARCHAR(32),
712 addressType TEXT, 804 regionType TEXT,
713 ipAssignedFree BIGINT, 805 ipAssignedFree BIGINT,
714 ipAssignedBusy BIGINT, 806 ipAssignedBusy BIGINT,
715 ipAvailable BIGINT, 807 ipAvailable BIGINT,
@@ -790,7 +882,7 @@ BEGIN
790 INNER JOIN netblock AS nb2 882 INNER JOIN netblock AS nb2
791 ON nb2.id = ip.netblockId 883 ON nb2.id = ip.netblockId
792 WHERE nb2.regionId IS NULL 884 WHERE nb2.regionId IS NULL
793 AND nb2.poolId IS NULL 885 AND nb2.poolId = pool.id
794 AND nb2.busyout IS FALSE 886 AND nb2.busyout IS FALSE
795 AND ip.nasId IS NOT NULL 887 AND ip.nasId IS NOT NULL
796 ) AS ipAssignFree, 888 ) AS ipAssignFree,
@@ -839,7 +931,7 @@ BEGIN
839 FROM netblock 931 FROM netblock
840 INNER JOIN pool 932 INNER JOIN pool
841 ON pool.id = netblock.poolId 933 ON pool.id = netblock.poolId
842 WHERE netblock.regionId IS NULL; 934 WHERE netblock.regionId IS NULL
843 UNION ALL 935 UNION ALL
844 SELECT DISTINCT pool.name AS poolName, 936 SELECT DISTINCT pool.name AS poolName,
845 'ALL' AS addressType, 937 'ALL' AS addressType,
@@ -848,7 +940,7 @@ BEGIN
848 FROM ip 940 FROM ip
849 INNER JOIN netblock AS nb2 941 INNER JOIN netblock AS nb2
850 ON nb2.id = ip.netblockId 942 ON nb2.id = ip.netblockId
851 WHERE nb2.poolId IS NULL 943 WHERE nb2.poolId = pool.id
852 AND nb2.busyout IS FALSE 944 AND nb2.busyout IS FALSE
853 AND ip.nasId IS NOT NULL 945 AND ip.nasId IS NOT NULL
854 ) AS ipAssignFree, 946 ) AS ipAssignFree,
@@ -900,11 +992,39 @@ $$;
900 992
901 993
902/* 994/*
903 * audits netblocks 995 * audits regions
904 * 996 *
905 * % SELECT * FROM netblock_audit(); 997 * % SELECT * FROM netblock_region();
998 *
999 * Returns table with the following columns:
1000 *
1001 * poolName
1002 * : name of pool which owns IP address
1003 *
1004 * regionName
1005 * : name of region
1006 *
1007 * ipAssignedFree
1008 * : number of IP addresses which are currently not busyout and are assigend
1009 * : to sessions
1010 *
1011 * ipAssignedBusy
1012 * : number of IP addresses which are currently busyout and are assigend to
1013 * : sessions
1014 *
1015 * ipAvailable
1016 * : number of IP addresses which are currently not busyout and not assigned to
1017 * : a session
1018 *
1019 * ipBusyout
1020 * : number of IP addresses currently marked as busyout
1021 *
1022 * ipTotal
1023 * : total number of IP addresses
1024 *
1025 * description
1026 * : human readable description of record
906 * 1027 *
907 * Returns table of netblocks
908 */ 1028 */
909CREATE OR REPLACE FUNCTION region_audit 1029CREATE OR REPLACE FUNCTION region_audit
910( 1030(