Skip to content

Commit 63f9607

Browse files
j-c-hdavem330
authored andcommitted
ppp: Add ppp_dev_name() exported function
ppp_dev_name() gives PPP users visibility of a ppp channel's device name. This can be used by L2TP drivers to dump the assigned PPP interface name. Signed-off-by: James Chapman <[email protected]> Reviewed-by: Randy Dunlap <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fd558d1 commit 63f9607

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

drivers/net/ppp_generic.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,6 +2162,24 @@ int ppp_unit_number(struct ppp_channel *chan)
21622162
return unit;
21632163
}
21642164

2165+
/*
2166+
* Return the PPP device interface name of a channel.
2167+
*/
2168+
char *ppp_dev_name(struct ppp_channel *chan)
2169+
{
2170+
struct channel *pch = chan->ppp;
2171+
char *name = NULL;
2172+
2173+
if (pch) {
2174+
read_lock_bh(&pch->upl);
2175+
if (pch->ppp && pch->ppp->dev)
2176+
name = pch->ppp->dev->name;
2177+
read_unlock_bh(&pch->upl);
2178+
}
2179+
return name;
2180+
}
2181+
2182+
21652183
/*
21662184
* Disconnect a channel from the generic layer.
21672185
* This must be called in process context.
@@ -2890,6 +2908,7 @@ EXPORT_SYMBOL(ppp_register_channel);
28902908
EXPORT_SYMBOL(ppp_unregister_channel);
28912909
EXPORT_SYMBOL(ppp_channel_index);
28922910
EXPORT_SYMBOL(ppp_unit_number);
2911+
EXPORT_SYMBOL(ppp_dev_name);
28932912
EXPORT_SYMBOL(ppp_input);
28942913
EXPORT_SYMBOL(ppp_input_error);
28952914
EXPORT_SYMBOL(ppp_output_wakeup);

include/linux/ppp_channel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ extern int ppp_channel_index(struct ppp_channel *);
7272
/* Get the unit number associated with a channel, or -1 if none */
7373
extern int ppp_unit_number(struct ppp_channel *);
7474

75+
/* Get the device name associated with a channel, or NULL if none */
76+
extern char *ppp_dev_name(struct ppp_channel *);
77+
7578
/*
7679
* SMP locking notes:
7780
* The channel code must ensure that when it calls ppp_unregister_channel,

0 commit comments

Comments
 (0)