Core Function Analysis
1. Main Entry Point (sites-available/gpon)
The main entry point defines the chronological execution of blocks. When a packet enters the GPON server block, it transits through the following core phases:
-
Authorize Executes full packet logging, runs the
gpon_auth_policy, and prepares thechapmodule for payload inspection. -
Authenticate Processes the prepared CHAP request. If the sub-module rejects the credentials, an explicit
Password Failuremessage is assigned to the reply. -
Accounting Routes traffic through
gpon_auth_policy(for parsing),fttx_session, and ultimatelygpon_accounting. -
Post-Auth Executes session bounds and cleans up the reply stream by stripping internal
User-Namevariables to prevent leakage. Logs standard Reject/Challenge statuses.
2. Authentication Handler (policy.d/gpon_auth_policy)
This policy serves as the critical gatekeeper for all GPON access requests.
2.1. How It works
Every time a user tries to connect, the policy runs through two stages:
User tries to connect
│
▼
STAGE 1: Input Check → Is the username even valid?
│
▼
STAGE 2: Find in Database → Does this user exist?
│
▼
ACCEPT or REJECT
2.2. Stage 1 - Input Checks (Is the username valid?)
Before doing anything else, the policy ensures the request is properly formed. If anything is wrong, it rejects immediately.
2.2.1. Check 1 — Required fields
The request must include both a username and a password. If either is missing, it is rejected.
REQUEST comes in
│
├── Has "User-Name"? → NO → REJECT "Missing User-Name"
├── Has "CHAP-Password"? → NO → REJECT "Missing Password"
│
└── Both present? → Continue
IF User-Name CONTAINS ' ':
REJECT "Invalid User-Name"
IF User-Name != LOWERCASE(User-Name):
REJECT "User-Name must be lowercase"
2.2.2. Check 2 — Lowercase and no spaces
Usernames must be all lowercase and must not contain spaces.
BAD: "John Doe" BAD: "John@isp.lk" GOOD: "john@isp.lk"
2.2.3. Check 3 — Single @ symbol
IF User-Name HAS MORE THAN ONE '@':
REJECT "Multiple @ in User-Name"
2.3. Stage 2 — Find the User in the Database
Once the username passes validation, it is normalized and used for database lookup.